@@ -440,6 +440,78 @@ describe('CompileFunctions', () => {
440
440
} ) ;
441
441
} ) ;
442
442
443
+ it ( 'should set the vpcConnector based on the function configuration' , ( ) => {
444
+ googlePackage . serverless . service . functions = {
445
+ func1 : {
446
+ handler : 'func1' ,
447
+ vpcConnector : 'projects/PROJECT_ID/locations/us-central1/connectors/my-connector' ,
448
+ events : [
449
+ { http : 'foo' } ,
450
+ ] ,
451
+ } ,
452
+ } ;
453
+
454
+ const compiledResources = [ {
455
+ type : 'cloudfunctions.v1beta2.function' ,
456
+ name : 'my-service-dev-func1' ,
457
+ properties : {
458
+ location : 'us-central1' ,
459
+ runtime : 'nodejs8' ,
460
+ function : 'func1' ,
461
+ availableMemoryMb : 256 ,
462
+ vpcConnector : 'projects/PROJECT_ID/locations/us-central1/connectors/my-connector' ,
463
+ timeout : '60s' ,
464
+ sourceArchiveUrl : 'gs://sls-my-service-dev-12345678/some-path/artifact.zip' ,
465
+ httpsTrigger : {
466
+ url : 'foo' ,
467
+ } ,
468
+ labels : { } ,
469
+ } ,
470
+ } ] ;
471
+
472
+ return googlePackage . compileFunctions ( ) . then ( ( ) => {
473
+ expect ( consoleLogStub . calledOnce ) . toEqual ( true ) ;
474
+ expect ( googlePackage . serverless . service . provider . compiledConfigurationTemplate . resources )
475
+ . toEqual ( compiledResources ) ;
476
+ } ) ;
477
+ } ) ;
478
+
479
+ it ( 'should set the vpcConnector based on the provider configuration' , ( ) => {
480
+ googlePackage . serverless . service . functions = {
481
+ func1 : {
482
+ handler : 'func1' ,
483
+ events : [
484
+ { http : 'foo' } ,
485
+ ] ,
486
+ } ,
487
+ } ;
488
+ googlePackage . serverless . service . provider . vpcConnector = 'projects/PROJECT_ID/locations/us-central1/connectors/my-connector' ;
489
+
490
+ const compiledResources = [ {
491
+ type : 'cloudfunctions.v1beta2.function' ,
492
+ name : 'my-service-dev-func1' ,
493
+ properties : {
494
+ location : 'us-central1' ,
495
+ runtime : 'nodejs8' ,
496
+ function : 'func1' ,
497
+ availableMemoryMb : 256 ,
498
+ vpcConnector : 'projects/PROJECT_ID/locations/us-central1/connectors/my-connector' ,
499
+ timeout : '60s' ,
500
+ sourceArchiveUrl : 'gs://sls-my-service-dev-12345678/some-path/artifact.zip' ,
501
+ httpsTrigger : {
502
+ url : 'foo' ,
503
+ } ,
504
+ labels : { } ,
505
+ } ,
506
+ } ] ;
507
+
508
+ return googlePackage . compileFunctions ( ) . then ( ( ) => {
509
+ expect ( consoleLogStub . calledOnce ) . toEqual ( true ) ;
510
+ expect ( googlePackage . serverless . service . provider . compiledConfigurationTemplate . resources )
511
+ . toEqual ( compiledResources ) ;
512
+ } ) ;
513
+ } ) ;
514
+
443
515
it ( 'should compile "http" events properly' , ( ) => {
444
516
googlePackage . serverless . service . functions = {
445
517
func1 : {
0 commit comments