@@ -122,6 +122,65 @@ describe('cleanup', () => {
122122 fseMock . copy . yields ( null , { } ) ;
123123 serverless . service . package . individually = true ;
124124
125+ const testFunctionsConfig = {
126+ func1 : {
127+ handler : 'module1.func1handler' ,
128+ package : {
129+ artifact : 'artifact-func1.zip' ,
130+ } ,
131+ events : [ {
132+ http : {
133+ method : 'get' ,
134+ path : 'func1path' ,
135+ } ,
136+ } ] ,
137+ } ,
138+ func2 : {
139+ handler : 'module2.func2handler' ,
140+ package : {
141+ artifact : 'artifact-func2.zip' ,
142+ } ,
143+ events : [ {
144+ http : {
145+ method : 'POST' ,
146+ path : 'func2path' ,
147+ } ,
148+ } , {
149+ nonhttp : 'non-http' ,
150+ } ] ,
151+ } ,
152+ func3 : {
153+ handler : 'module2.func3handler' ,
154+ package : {
155+ artifact : 'artifact-func3.zip' ,
156+ } ,
157+ events : [ {
158+ nonhttp : 'non-http' ,
159+ } ] ,
160+ } ,
161+ } ;
162+ serverless . service . functions = testFunctionsConfig ;
163+
164+ return expect ( module . cleanup ( ) ) . to . be . fulfilled
165+ . then ( ( ) => {
166+ expect ( serverless . config . servicePath ) . to . equal ( 'my/Original/Service/Path' ) ;
167+ expect ( fseMock . copy ) . to . have . been . calledOnce ;
168+ expect ( fseMock . copy ) . to . have . been
169+ . calledWith ( 'my/Output/Path/.serverless' , 'my/Original/Service/Path/.serverless' ) ;
170+ _ . forEach ( [ 'func1' , 'func2' , 'func3' ] , funcName => {
171+ expect ( serverless . service . functions [ funcName ] . package ) . to . have . a . property ( 'artifact' )
172+ . that . equals ( `my/Original/Service/Path/.serverless/artifact-${ funcName } .zip` ) ;
173+ } ) ;
174+ } ) ;
175+ } ) ;
176+
177+ it ( 'should call copy with the right parameters with individual packaging for old Serverless versions (<=1.17)' , ( ) => {
178+ dirExistsSyncStub . returns ( true ) ;
179+ module . originalServicePath = 'my/Original/Service/Path' ;
180+ fseMock . copy . reset ( ) ;
181+ fseMock . copy . yields ( null , { } ) ;
182+ serverless . service . package . individually = true ;
183+
125184 const testFunctionsConfig = {
126185 func1 : {
127186 handler : 'module1.func1handler' ,
0 commit comments