@@ -120,6 +120,7 @@ describe('CompileFunctions', () => {
120
120
httpsTrigger : {
121
121
url : 'foo' ,
122
122
} ,
123
+ labels : { } ,
123
124
} ,
124
125
} ] ;
125
126
@@ -153,6 +154,7 @@ describe('CompileFunctions', () => {
153
154
httpsTrigger : {
154
155
url : 'foo' ,
155
156
} ,
157
+ labels : { } ,
156
158
} ,
157
159
} ] ;
158
160
@@ -186,6 +188,7 @@ describe('CompileFunctions', () => {
186
188
httpsTrigger : {
187
189
url : 'foo' ,
188
190
} ,
191
+ labels : { } ,
189
192
} ,
190
193
} ] ;
191
194
@@ -219,6 +222,126 @@ describe('CompileFunctions', () => {
219
222
httpsTrigger : {
220
223
url : 'foo' ,
221
224
} ,
225
+ labels : { } ,
226
+ } ,
227
+ } ] ;
228
+
229
+ return googlePackage . compileFunctions ( ) . then ( ( ) => {
230
+ expect ( consoleLogStub . calledOnce ) . toEqual ( true ) ;
231
+ expect ( googlePackage . serverless . service . provider . compiledConfigurationTemplate . resources )
232
+ . toEqual ( compiledResources ) ;
233
+ } ) ;
234
+ } ) ;
235
+
236
+ it ( 'should set the labels based on the functions configuration' , ( ) => {
237
+ googlePackage . serverless . service . functions = {
238
+ func1 : {
239
+ handler : 'func1' ,
240
+ labels : {
241
+ test : 'label'
242
+ } ,
243
+ events : [
244
+ { http : 'foo' } ,
245
+ ] ,
246
+ } ,
247
+ } ;
248
+
249
+ const compiledResources = [ {
250
+ type : 'cloudfunctions.v1beta2.function' ,
251
+ name : 'my-service-dev-func1' ,
252
+ properties : {
253
+ location : 'us-central1' ,
254
+ function : 'func1' ,
255
+ availableMemoryMb : 256 ,
256
+ timeout : '60s' ,
257
+ sourceArchiveUrl : 'gs://sls-my-service-dev-12345678/some-path/artifact.zip' ,
258
+ httpsTrigger : {
259
+ url : 'foo' ,
260
+ } ,
261
+ labels : {
262
+ test : 'label'
263
+ } ,
264
+ } ,
265
+ } ] ;
266
+
267
+ return googlePackage . compileFunctions ( ) . then ( ( ) => {
268
+ expect ( consoleLogStub . calledOnce ) . toEqual ( true ) ;
269
+ expect ( googlePackage . serverless . service . provider . compiledConfigurationTemplate . resources )
270
+ . toEqual ( compiledResources ) ;
271
+ } ) ;
272
+ } ) ;
273
+
274
+ it ( 'should set the labels based on the provider configuration' , ( ) => {
275
+ googlePackage . serverless . service . functions = {
276
+ func1 : {
277
+ handler : 'func1' ,
278
+ events : [
279
+ { http : 'foo' } ,
280
+ ] ,
281
+ } ,
282
+ } ;
283
+ googlePackage . serverless . service . provider . labels = {
284
+ test : 'label'
285
+ } ;
286
+
287
+ const compiledResources = [ {
288
+ type : 'cloudfunctions.v1beta2.function' ,
289
+ name : 'my-service-dev-func1' ,
290
+ properties : {
291
+ location : 'us-central1' ,
292
+ function : 'func1' ,
293
+ availableMemoryMb : 256 ,
294
+ timeout : '60s' ,
295
+ sourceArchiveUrl : 'gs://sls-my-service-dev-12345678/some-path/artifact.zip' ,
296
+ httpsTrigger : {
297
+ url : 'foo' ,
298
+ } ,
299
+ labels : {
300
+ test : 'label'
301
+ } ,
302
+ } ,
303
+ } ] ;
304
+
305
+ return googlePackage . compileFunctions ( ) . then ( ( ) => {
306
+ expect ( consoleLogStub . calledOnce ) . toEqual ( true ) ;
307
+ expect ( googlePackage . serverless . service . provider . compiledConfigurationTemplate . resources )
308
+ . toEqual ( compiledResources ) ;
309
+ } ) ;
310
+ } ) ;
311
+
312
+ it ( 'should set the labels based on the merged provider and function configuration' , ( ) => {
313
+ googlePackage . serverless . service . functions = {
314
+ func1 : {
315
+ handler : 'func1' ,
316
+ events : [
317
+ { http : 'foo' } ,
318
+ ] ,
319
+ labels : {
320
+ test : 'functionLabel'
321
+ }
322
+ } ,
323
+ } ;
324
+ googlePackage . serverless . service . provider . labels = {
325
+ test : 'providerLabel' ,
326
+ secondTest : 'tested' ,
327
+ } ;
328
+
329
+ const compiledResources = [ {
330
+ type : 'cloudfunctions.v1beta2.function' ,
331
+ name : 'my-service-dev-func1' ,
332
+ properties : {
333
+ location : 'us-central1' ,
334
+ function : 'func1' ,
335
+ availableMemoryMb : 256 ,
336
+ timeout : '60s' ,
337
+ sourceArchiveUrl : 'gs://sls-my-service-dev-12345678/some-path/artifact.zip' ,
338
+ httpsTrigger : {
339
+ url : 'foo' ,
340
+ } ,
341
+ labels : {
342
+ test : 'functionLabel' ,
343
+ secondTest : 'tested' ,
344
+ } ,
222
345
} ,
223
346
} ] ;
224
347
@@ -251,6 +374,7 @@ describe('CompileFunctions', () => {
251
374
httpsTrigger : {
252
375
url : 'foo' ,
253
376
} ,
377
+ labels : { } ,
254
378
} ,
255
379
} ] ;
256
380
@@ -303,6 +427,7 @@ describe('CompileFunctions', () => {
303
427
path : 'some-path' ,
304
428
resource : 'some-resource' ,
305
429
} ,
430
+ labels : { } ,
306
431
} ,
307
432
} ,
308
433
{
@@ -318,6 +443,7 @@ describe('CompileFunctions', () => {
318
443
eventType : 'foo' ,
319
444
resource : 'some-resource' ,
320
445
} ,
446
+ labels : { } ,
321
447
} ,
322
448
} ,
323
449
] ;
0 commit comments