@@ -36,6 +36,25 @@ describe('OpenWhiskCompilePackages', () => {
36
36
sandbox . restore ( ) ;
37
37
} ) ;
38
38
39
+ describe ( '#renameManifestPackages()' , ( ) => {
40
+ it ( 'should rename packages with explicit names' , ( ) => {
41
+ openwhiskCompilePackages . serverless . service . resources . packages = {
42
+ 'first' : { name : 'firstchanged' , parameters : { hello : 'world first' } } ,
43
+ 'second' : { parameters : { hello : 'world second' } }
44
+ } ;
45
+
46
+ const expected = {
47
+ 'firstchanged' : { name : 'firstchanged' , parameters : { hello : 'world first' } } ,
48
+ 'second' : { parameters : { hello : 'world second' } }
49
+ } ;
50
+
51
+ openwhiskCompilePackages . renameManifestPackages ( ) ;
52
+ expect ( openwhiskCompilePackages . serverless . service . resources . packages )
53
+ . to . deep . equal ( expected ) ;
54
+
55
+ } )
56
+ } )
57
+
39
58
describe ( '#getActionPackages()' , ( ) => {
40
59
it ( 'should return no package names for functions without name property' , ( ) => {
41
60
const service = openwhiskCompilePackages . serverless . service ;
@@ -140,6 +159,46 @@ describe('OpenWhiskCompilePackages', () => {
140
159
. to . deep . equal ( { sample : expected } )
141
160
) ) . to . eventually . be . fulfilled ;
142
161
} ) ;
162
+
163
+ it ( 'should merge packages with explicit names' , ( ) => {
164
+ openwhiskCompilePackages . serverless . service . resources . packages = {
165
+ 'first' : { name : 'firstchanged' , parameters : { hello : 'world first' } } ,
166
+ 'second' : { parameters : { hello : 'world second' } }
167
+ } ;
168
+
169
+ sandbox . stub ( openwhiskCompilePackages , 'getActionPackages' , ( ) => [ 'firstchanged' , 'second' , 'third' ] ) ;
170
+
171
+ const expected = {
172
+ firstchanged : {
173
+ name : 'firstchanged' ,
174
+ overwrite : true ,
175
+ package : { parameters : [ { key : 'hello' , value : 'world first' } ] } ,
176
+ namespace : 'testing'
177
+ } ,
178
+ second : {
179
+ name : 'second' ,
180
+ overwrite : true ,
181
+ package : { parameters : [ { key : 'hello' , value : 'world second' } ] } ,
182
+ namespace : 'testing'
183
+ } ,
184
+ third : {
185
+ name : 'third' ,
186
+ overwrite : true ,
187
+ package : { } ,
188
+ namespace : 'testing'
189
+ }
190
+ } ;
191
+
192
+ // Simulate hooks
193
+ openwhiskCompilePackages . setup ( ) ;
194
+ openwhiskCompilePackages . renameManifestPackages ( ) ;
195
+ openwhiskCompilePackages . mergeActionPackages ( ) ;
196
+
197
+ return expect ( openwhiskCompilePackages . compilePackages ( ) . then ( ( ) => {
198
+ expect ( openwhiskCompilePackages . serverless . service . packages )
199
+ . to . deep . equal ( expected )
200
+ } ) ) . to . eventually . be . fulfilled ;
201
+ } ) ;
143
202
} ) ;
144
203
describe ( '#compilePackage()' , ( ) => {
145
204
it ( 'should define packages without a body' , ( ) => {
0 commit comments