Skip to content

Commit 35b0ce2

Browse files
author
bweigel
committed
start implementing tests
1 parent 29f383b commit 35b0ce2

File tree

6 files changed

+33
-4
lines changed

6 files changed

+33
-4
lines changed

lib/inject.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@ function injectAllRequirements(funcArtifact) {
116116
return this.options.zip
117117
? func
118118
: injectRequirements(
119-
path.join('.serverless', func.module, 'requirements'),
120-
func.package.artifact,
121-
this.options
122-
);
119+
path.join('.serverless', func.module, 'requirements'),
120+
func.package.artifact,
121+
this.options
122+
);
123123
});
124124
} else if (!this.options.zip) {
125125
return injectRequirements(

test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,19 @@ test('py3.6 can package flask with slim option', t => {
134134
);
135135
t.end();
136136
});
137+
138+
test('can package individually without moving modules to root of zip-File', t => {
139+
process.chdir('tests/base');
140+
const path = npm(['pack', '../..']);
141+
npm(['i', path]);
142+
sls(['--individually=true', '--moveup=false', 'package']);
143+
const zipfiles = listZipFiles(
144+
'.serverless/fn2-sls-py-req-test-dev-hello4.zip'
145+
);
146+
t.true(
147+
zipfiles.includes(`fn2${sep}__init__.py`),
148+
'fn2 is packaged as module'
149+
);
150+
t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged');
151+
t.end();
152+
});

tests/base/fn2/__init__.py

Whitespace-only changes.

tests/base/fn2/handler.py

Lines changed: 5 additions & 0 deletions
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/fn2/requirements.txt

Whitespace-only changes.

tests/base/serverless.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ custom:
1414
slimPatterns: ${file(./slimPatterns.yml):slimPatterns, self:custom.defaults.slimPatterns}
1515
vendor: ${opt:vendor, ''}
1616
fileName: ${opt:fileName, 'requirements.txt'}
17+
IndividuallyMoveUpModules: ${opt:moveup, self:custom.defaults.IndividuallyMoveUpModules}
1718
defaults:
1819
slim: false
1920
slimPatterns: false
2021
zip: false
2122
dockerizePip: false
2223
individually: false
24+
IndividuallyMoveUpModules: true
2325

2426
package:
2527
individually: ${opt:individually, self:custom.defaults.individually}
@@ -36,3 +38,9 @@ functions:
3638
hello3:
3739
handler: handler.hello
3840
runtime: nodejs6.10
41+
hello4:
42+
handler: fn2.handler.hello
43+
module: fn2
44+
package:
45+
include:
46+
- 'fn2/**'

0 commit comments

Comments
 (0)