Skip to content

Commit 136baf0

Browse files
author
bweigel
committed
adds test for IndividuallyMoveUpModules=true
1 parent 3f3d46d commit 136baf0

File tree

4 files changed

+92
-1
lines changed

4 files changed

+92
-1
lines changed

test.js

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,97 @@ test('can package individually, moving modules to root of zip-File with Individu
499499
t.end();
500500
});
501501

502+
test('can package individually, moving modules to root of zip-File with IndividuallyMoveUpModules=true', t => {
503+
process.chdir('tests/base');
504+
const path = npm(['pack', '../..']);
505+
npm(['i', path]);
506+
sls(['--individually=true', '--moveup=true', 'package']);
507+
508+
const zipfiles_hello = listZipFiles('.serverless/hello.zip');
509+
t.false(
510+
zipfiles_hello.includes(`fn2${sep}__init__.py`),
511+
'fn2 is not packaged in function hello'
512+
);
513+
t.true(
514+
zipfiles_hello.includes('handler.py'),
515+
'handler.py is packaged in function hello'
516+
);
517+
t.false(
518+
zipfiles_hello.includes(`dataclasses.py`),
519+
'dataclasses is not packaged in function hello'
520+
);
521+
t.true(
522+
zipfiles_hello.includes(`flask${sep}__init__.py`),
523+
'flask is packaged in function hello'
524+
);
525+
526+
const zipfiles_hello4 = listZipFiles(
527+
'.serverless/fn2-sls-py-req-test-dev-hello4.zip'
528+
);
529+
t.true(
530+
zipfiles_hello4.includes(`other.py`),
531+
'fn2 is moved to root in function hello4'
532+
);
533+
t.true(
534+
zipfiles_hello4.includes(`dataclasses.py`),
535+
'dataclasses is packaged in function hello4'
536+
);
537+
t.false(
538+
zipfiles_hello4.includes(`flask${sep}__init__.py`),
539+
'flask is not packaged in function hello4'
540+
);
541+
t.false(
542+
zipfiles_hello4.includes(`common${sep}__init__.py`),
543+
'module common is not packaged in function hello4'
544+
);
545+
546+
const zipfiles_hello5 = listZipFiles(
547+
'.serverless/fn2-sls-py-req-test-dev-hello5.zip'
548+
);
549+
t.true(
550+
zipfiles_hello5.includes(`other.py`),
551+
'fn2 is moved to root in function hello5'
552+
);
553+
t.true(
554+
zipfiles_hello5.includes(`dataclasses.py`),
555+
'dataclasses is packaged in function hello5'
556+
);
557+
t.false(
558+
zipfiles_hello5.includes(`flask${sep}__init__.py`),
559+
'flask is not packaged in function hello5'
560+
);
561+
t.true(
562+
zipfiles_hello5.includes(`common${sep}__init__.py`),
563+
'module common is packaged in function hello5'
564+
);
565+
566+
const zipfiles_hello6 = listZipFiles(
567+
'.serverless/fn3-sls-py-req-test-dev-hello6.zip'
568+
);
569+
t.true(
570+
zipfiles_hello6.includes(`fn3_handler.py`),
571+
'fn3 is moved to root in function hello6'
572+
);
573+
t.false(
574+
zipfiles_hello6.includes(`fn2${sep}__init__.py`),
575+
'fn2 is not packaged in function hello6'
576+
);
577+
t.false(
578+
zipfiles_hello6.includes(`dataclasses.py`),
579+
'dataclasses is packaged in function hello6'
580+
);
581+
t.false(
582+
zipfiles_hello6.includes(`flask${sep}__init__.py`),
583+
'flask is not packaged in function hello6'
584+
);
585+
t.true(
586+
zipfiles_hello6.includes(`common${sep}__init__.py`),
587+
'module common is packaged in function hello6'
588+
);
589+
590+
t.end();
591+
});
592+
502593
/*
503594
* News tests not in test.bats
504595
*/

tests/base/fn2/other.py

Whitespace-only changes.
File renamed without changes.

tests/base/serverless.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ functions:
5656
- 'fn2/**'
5757
- 'common/__init__.py'
5858
hello6:
59-
handler: fn3.handler.hello
59+
handler: fn3.fn3_handler.hello
6060
module: fn3
6161
package:
6262
include:

0 commit comments

Comments
 (0)