File tree Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ module.exports = {
44
44
|| _ . get ( this , 'serverless.service.provider.timeout' )
45
45
|| '60s' ;
46
46
funcTemplate . properties . environmentVariables = _ . merge (
47
+ { } ,
47
48
_ . get ( this , 'serverless.service.provider.environment' ) ,
48
49
funcObject . environment // eslint-disable-line comma-dangle
49
50
) ;
Original file line number Diff line number Diff line change @@ -440,6 +440,59 @@ describe('CompileFunctions', () => {
440
440
} ) ;
441
441
} ) ;
442
442
443
+ it ( 'should merge the environment variables on the provider configuration and function definition' , ( ) => {
444
+ googlePackage . serverless . service . functions = {
445
+ func1 : {
446
+ handler : 'func1' ,
447
+ environment : {
448
+ TEST_VAR : 'test_var' ,
449
+ TEST_VALUE : 'foobar' ,
450
+ } ,
451
+ events : [
452
+ { http : 'foo' } ,
453
+ ] ,
454
+ } ,
455
+ } ;
456
+ googlePackage . serverless . service . provider . environment = {
457
+ TEST_VAR : 'test' ,
458
+ TEST_FOO : 'foo' ,
459
+ } ;
460
+
461
+ const compiledResources = [ {
462
+ type : 'gcp-types/cloudfunctions-v1:projects.locations.functions' ,
463
+ name : 'my-service-dev-func1' ,
464
+ properties : {
465
+ parent : 'projects/myProject/locations/us-central1' ,
466
+ runtime : 'nodejs8' ,
467
+ function : 'my-service-dev-func1' ,
468
+ entryPoint : 'func1' ,
469
+ availableMemoryMb : 256 ,
470
+ environmentVariables : {
471
+ TEST_VAR : 'test_var' ,
472
+ TEST_VALUE : 'foobar' ,
473
+ TEST_FOO : 'foo' ,
474
+ } ,
475
+ timeout : '60s' ,
476
+ sourceArchiveUrl : 'gs://sls-my-service-dev-12345678/some-path/artifact.zip' ,
477
+ httpsTrigger : {
478
+ url : 'foo' ,
479
+ } ,
480
+ labels : { } ,
481
+ } ,
482
+ } ] ;
483
+
484
+ return googlePackage . compileFunctions ( ) . then ( ( ) => {
485
+ expect ( consoleLogStub . calledOnce ) . toEqual ( true ) ;
486
+ expect ( googlePackage . serverless . service . provider . compiledConfigurationTemplate . resources )
487
+ . toEqual ( compiledResources ) ;
488
+ expect ( googlePackage . serverless . service . provider . environment )
489
+ . toEqual ( {
490
+ TEST_VAR : 'test' ,
491
+ TEST_FOO : 'foo' ,
492
+ } ) ;
493
+ } ) ;
494
+ } ) ;
495
+
443
496
it ( 'should compile "http" events properly' , ( ) => {
444
497
googlePackage . serverless . service . functions = {
445
498
func1 : {
You can’t perform that action at this time.
0 commit comments