Skip to content

Commit 087c5be

Browse files
author
bweigel
committed
adds more tests
1 parent db0b587 commit 087c5be

File tree

4 files changed

+104
-0
lines changed

4 files changed

+104
-0
lines changed

test.js

+92
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ test('can package individually without moving modules to root of zip-File', t =>
148148
npm(['i', path]);
149149
sls(['--individually=true', '--moveup=false', 'package']);
150150

151+
151152
const zipfiles_hello = listZipFiles('.serverless/hello.zip');
152153
t.false(
153154
zipfiles_hello.includes(`fn2${sep}__init__.py`),
@@ -179,6 +180,10 @@ test('can package individually without moving modules to root of zip-File', t =>
179180
zipfiles_hello4.includes(`flask${sep}__init__.py`),
180181
'flask is not packaged in function hello4'
181182
);
183+
t.false(
184+
zipfiles_hello4.includes(`common${sep}__init__.py`),
185+
'module common is not packaged in function hello4'
186+
);
182187

183188
const zipfiles_hello5 = listZipFiles('.serverless/hello5.zip');
184189
t.true(
@@ -193,6 +198,32 @@ test('can package individually without moving modules to root of zip-File', t =>
193198
zipfiles_hello5.includes(`flask${sep}__init__.py`),
194199
'flask is not packaged in function hello5'
195200
);
201+
t.true(
202+
zipfiles_hello5.includes(`common${sep}__init__.py`),
203+
'module common is packaged in function hello5'
204+
);
205+
206+
const zipfiles_hello6 = listZipFiles('.serverless/hello6.zip');
207+
t.true(
208+
zipfiles_hello6.includes(`fn3${sep}__init__.py`),
209+
'fn3 is packaged as module in function hello6'
210+
);
211+
t.false(
212+
zipfiles_hello6.includes(`fn2${sep}__init__.py`),
213+
'fn2 is not packaged in function hello6'
214+
);
215+
t.false(
216+
zipfiles_hello6.includes(`dataclasses.py`),
217+
'dataclasses is packaged in function hello6'
218+
);
219+
t.false(
220+
zipfiles_hello6.includes(`flask${sep}__init__.py`),
221+
'flask is not packaged in function hello6'
222+
);
223+
t.true(
224+
zipfiles_hello6.includes(`common${sep}__init__.py`),
225+
'module common is packaged in function hello6'
226+
);
196227

197228
t.end();
198229
});
@@ -234,6 +265,10 @@ test('can package individually without moving modules to root of zip-File with o
234265
zipfiles_hello4.includes(`flask${sep}__init__.py`),
235266
'flask is not packaged in function hello4'
236267
);
268+
t.false(
269+
zipfiles_hello4.includes(`common${sep}__init__.py`),
270+
'module common is not packaged in function hello4'
271+
);
237272

238273
const zipfiles_hello5 = listZipFiles('.serverless/hello5.zip');
239274
t.true(
@@ -248,6 +283,32 @@ test('can package individually without moving modules to root of zip-File with o
248283
zipfiles_hello5.includes(`flask${sep}__init__.py`),
249284
'flask is not packaged in function hello5'
250285
);
286+
t.true(
287+
zipfiles_hello5.includes(`common${sep}__init__.py`),
288+
'module common is packaged in function hello5'
289+
);
290+
291+
const zipfiles_hello6 = listZipFiles('.serverless/hello6.zip');
292+
t.true(
293+
zipfiles_hello6.includes(`fn3${sep}__init__.py`),
294+
'fn3 is packaged as module in function hello6'
295+
);
296+
t.false(
297+
zipfiles_hello6.includes(`fn2${sep}__init__.py`),
298+
'fn2 is not packaged in function hello6'
299+
);
300+
t.false(
301+
zipfiles_hello6.includes(`dataclasses.py`),
302+
'dataclasses is packaged in function hello6'
303+
);
304+
t.false(
305+
zipfiles_hello6.includes(`flask${sep}__init__.py`),
306+
'flask is not packaged in function hello6'
307+
);
308+
t.true(
309+
zipfiles_hello6.includes(`common${sep}__init__.py`),
310+
'module common is packaged in function hello6'
311+
);
251312

252313
t.end();
253314
});
@@ -258,6 +319,7 @@ test('can package individually without moving modules to root of zip-File with u
258319
npm(['i', path]);
259320
sls(['--individually=true', '--moveup=false', '--useStaticCache=true', '--useDownloadCache=true', 'package']);
260321

322+
261323
const zipfiles_hello = listZipFiles('.serverless/hello.zip');
262324
t.false(
263325
zipfiles_hello.includes(`fn2${sep}__init__.py`),
@@ -289,6 +351,10 @@ test('can package individually without moving modules to root of zip-File with u
289351
zipfiles_hello4.includes(`flask${sep}__init__.py`),
290352
'flask is not packaged in function hello4'
291353
);
354+
t.false(
355+
zipfiles_hello4.includes(`common${sep}__init__.py`),
356+
'module common is not packaged in function hello4'
357+
);
292358

293359
const zipfiles_hello5 = listZipFiles('.serverless/hello5.zip');
294360
t.true(
@@ -303,6 +369,32 @@ test('can package individually without moving modules to root of zip-File with u
303369
zipfiles_hello5.includes(`flask${sep}__init__.py`),
304370
'flask is not packaged in function hello5'
305371
);
372+
t.true(
373+
zipfiles_hello5.includes(`common${sep}__init__.py`),
374+
'module common is packaged in function hello5'
375+
);
376+
377+
const zipfiles_hello6 = listZipFiles('.serverless/hello6.zip');
378+
t.true(
379+
zipfiles_hello6.includes(`fn3${sep}__init__.py`),
380+
'fn3 is packaged as module in function hello6'
381+
);
382+
t.false(
383+
zipfiles_hello6.includes(`fn2${sep}__init__.py`),
384+
'fn2 is not packaged in function hello6'
385+
);
386+
t.false(
387+
zipfiles_hello6.includes(`dataclasses.py`),
388+
'dataclasses is packaged in function hello6'
389+
);
390+
t.false(
391+
zipfiles_hello6.includes(`flask${sep}__init__.py`),
392+
'flask is not packaged in function hello6'
393+
);
394+
t.true(
395+
zipfiles_hello6.includes(`common${sep}__init__.py`),
396+
'module common is packaged in function hello6'
397+
);
306398

307399
t.end();
308400
});

tests/base/fn3/__init__.py

Whitespace-only changes.

tests/base/fn3/handler.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import requests
2+
3+
4+
def hello(event, context):
5+
return requests.get("https://httpbin.org/get").json()

tests/base/serverless.yml

+7
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,10 @@ functions:
5555
include:
5656
- 'fn2/**'
5757
- 'common/__init__.py'
58+
hello6:
59+
handler: fn3.handler.hello
60+
module: fn3
61+
package:
62+
include:
63+
- 'fn3/**'
64+
- 'common/__init__.py'

0 commit comments

Comments
 (0)