@@ -360,6 +360,86 @@ describe('CompileFunctions', () => {
360
360
} ) ;
361
361
} ) ;
362
362
363
+ it ( 'should set the environment variables based on the function configuration' , ( ) => {
364
+ googlePackage . serverless . service . functions = {
365
+ func1 : {
366
+ handler : 'func1' ,
367
+ environment : {
368
+ TEST_VAR : 'test' ,
369
+ } ,
370
+ events : [
371
+ { http : 'foo' } ,
372
+ ] ,
373
+ } ,
374
+ } ;
375
+
376
+ const compiledResources = [ {
377
+ type : 'cloudfunctions.v1beta2.function' ,
378
+ name : 'my-service-dev-func1' ,
379
+ properties : {
380
+ location : 'us-central1' ,
381
+ runtime : 'nodejs8' ,
382
+ function : 'func1' ,
383
+ availableMemoryMb : 256 ,
384
+ environmentVariables : {
385
+ TEST_VAR : 'test' ,
386
+ } ,
387
+ timeout : '60s' ,
388
+ sourceArchiveUrl : 'gs://sls-my-service-dev-12345678/some-path/artifact.zip' ,
389
+ httpsTrigger : {
390
+ url : 'foo' ,
391
+ } ,
392
+ labels : { } ,
393
+ } ,
394
+ } ] ;
395
+
396
+ return googlePackage . compileFunctions ( ) . then ( ( ) => {
397
+ expect ( consoleLogStub . calledOnce ) . toEqual ( true ) ;
398
+ expect ( googlePackage . serverless . service . provider . compiledConfigurationTemplate . resources )
399
+ . toEqual ( compiledResources ) ;
400
+ } ) ;
401
+ } ) ;
402
+
403
+ it ( 'should set the environment variables based on the provider configuration' , ( ) => {
404
+ googlePackage . serverless . service . functions = {
405
+ func1 : {
406
+ handler : 'func1' ,
407
+ events : [
408
+ { http : 'foo' } ,
409
+ ] ,
410
+ } ,
411
+ } ;
412
+ googlePackage . serverless . service . provider . environment = {
413
+ TEST_VAR : 'test' ,
414
+ } ;
415
+
416
+ const compiledResources = [ {
417
+ type : 'cloudfunctions.v1beta2.function' ,
418
+ name : 'my-service-dev-func1' ,
419
+ properties : {
420
+ location : 'us-central1' ,
421
+ runtime : 'nodejs8' ,
422
+ function : 'func1' ,
423
+ availableMemoryMb : 256 ,
424
+ environmentVariables : {
425
+ TEST_VAR : 'test' ,
426
+ } ,
427
+ timeout : '60s' ,
428
+ sourceArchiveUrl : 'gs://sls-my-service-dev-12345678/some-path/artifact.zip' ,
429
+ httpsTrigger : {
430
+ url : 'foo' ,
431
+ } ,
432
+ labels : { } ,
433
+ } ,
434
+ } ] ;
435
+
436
+ return googlePackage . compileFunctions ( ) . then ( ( ) => {
437
+ expect ( consoleLogStub . calledOnce ) . toEqual ( true ) ;
438
+ expect ( googlePackage . serverless . service . provider . compiledConfigurationTemplate . resources )
439
+ . toEqual ( compiledResources ) ;
440
+ } ) ;
441
+ } ) ;
442
+
363
443
it ( 'should compile "http" events properly' , ( ) => {
364
444
googlePackage . serverless . service . functions = {
365
445
func1 : {
0 commit comments