@@ -459,13 +459,12 @@ describe('CompileFunctions', () => {
459
459
} ;
460
460
461
461
const compiledResources = [ {
462
- type : 'gcp-types/ cloudfunctions-v1:projects.locations.functions ' ,
462
+ type : 'cloudfunctions.v1beta2.function ' ,
463
463
name : 'my-service-dev-func1' ,
464
464
properties : {
465
- parent : 'projects/myProject/locations/ us-central1' ,
465
+ location : 'us-central1' ,
466
466
runtime : 'nodejs8' ,
467
- function : 'my-service-dev-func1' ,
468
- entryPoint : 'func1' ,
467
+ function : 'func1' ,
469
468
availableMemoryMb : 256 ,
470
469
environmentVariables : {
471
470
TEST_VAR : 'test_var' ,
@@ -598,5 +597,44 @@ describe('CompileFunctions', () => {
598
597
. toEqual ( compiledResources ) ;
599
598
} ) ;
600
599
} ) ;
600
+
601
+ it ( 'should set vpc connection base on the function configuration' , ( ) => {
602
+ googlePackage . serverless . service . functions = {
603
+ func1 : {
604
+ handler : 'func1' ,
605
+ memorySize : 128 ,
606
+ runtime : 'nodejs8' ,
607
+ vpc : 'projects/pg-us-n-app-123456/locations/us-central1/connectors/my-vpc' ,
608
+ events : [
609
+ { http : 'foo' } ,
610
+ ] ,
611
+ } ,
612
+ } ;
613
+
614
+ const compiledResources = [ {
615
+ type : 'cloudfunctions.v1beta2.function' ,
616
+ name : 'my-service-dev-func1' ,
617
+ properties : {
618
+ location : 'us-central1' ,
619
+ runtime : 'nodejs8' ,
620
+ function : 'func1' ,
621
+ availableMemoryMb : 128 ,
622
+ timeout : '60s' ,
623
+ sourceArchiveUrl : 'gs://sls-my-service-dev-12345678/some-path/artifact.zip' ,
624
+ httpsTrigger : {
625
+ url : 'foo' ,
626
+ } ,
627
+ labels : { } ,
628
+ vpcConnector : 'projects/pg-us-n-app-123456/locations/us-central1/connectors/my-vpc' ,
629
+ } ,
630
+ } ] ;
631
+
632
+ return googlePackage . compileFunctions ( ) . then ( ( ) => {
633
+ expect ( consoleLogStub . called ) . toEqual ( true ) ;
634
+ expect ( googlePackage . serverless . service . provider . compiledConfigurationTemplate . resources )
635
+ . toEqual ( compiledResources ) ;
636
+ } ) ;
637
+ } ) ;
601
638
} ) ;
602
639
} ) ;
640
+
0 commit comments