@@ -766,6 +766,115 @@ describe('CompileFunctions', () => {
766
766
) . toEqual ( compiledResources ) ;
767
767
} ) ;
768
768
} ) ;
769
+
770
+ it ( 'should set min instances on the function configuration' , ( ) => {
771
+ googlePackage . serverless . service . functions = {
772
+ func1 : {
773
+ handler : 'func1' ,
774
+ memorySize : 128 ,
775
+ runtime : 'nodejs10' ,
776
+ minInstances : 5 ,
777
+ vpc : 'projects/pg-us-n-app-123456/locations/us-central1/connectors/my-vpc' ,
778
+ events : [ { http : 'foo' } ] ,
779
+ } ,
780
+ } ;
781
+
782
+ const compiledResources = [
783
+ {
784
+ type : 'gcp-types/cloudfunctions-v1:projects.locations.functions' ,
785
+ name : 'my-service-dev-func1' ,
786
+ properties : {
787
+ parent : 'projects/myProject/locations/us-central1' ,
788
+ runtime : 'nodejs10' ,
789
+ function : 'my-service-dev-func1' ,
790
+ entryPoint : 'func1' ,
791
+ availableMemoryMb : 128 ,
792
+ timeout : '60s' ,
793
+ minInstances : 5 ,
794
+ sourceArchiveUrl : 'gs://sls-my-service-dev-12345678/some-path/artifact.zip' ,
795
+ httpsTrigger : {
796
+ url : 'foo' ,
797
+ } ,
798
+ labels : { } ,
799
+ vpcConnector : 'projects/pg-us-n-app-123456/locations/us-central1/connectors/my-vpc' ,
800
+ } ,
801
+ } ,
802
+ ] ;
803
+
804
+ return googlePackage . compileFunctions ( ) . then ( ( ) => {
805
+ expect ( consoleLogStub . called ) . toEqual ( true ) ;
806
+ expect (
807
+ googlePackage . serverless . service . provider . compiledConfigurationTemplate . resources
808
+ ) . toEqual ( compiledResources ) ;
809
+ } ) ;
810
+ } ) ;
811
+
812
+ it ( 'should not require min instances on each function configuration' , ( ) => {
813
+ googlePackage . serverless . service . functions = {
814
+ func1 : {
815
+ handler : 'func1' ,
816
+ memorySize : 128 ,
817
+ runtime : 'nodejs10' ,
818
+ vpc : 'projects/pg-us-n-app-123456/locations/us-central1/connectors/my-vpc' ,
819
+ events : [ { http : 'foo' } ] ,
820
+ } ,
821
+ func2 : {
822
+ handler : 'func2' ,
823
+ memorySize : 128 ,
824
+ runtime : 'nodejs10' ,
825
+ minInstances : 5 ,
826
+ vpc : 'projects/pg-us-n-app-123456/locations/us-central1/connectors/my-vpc' ,
827
+ events : [ { http : 'bar' } ] ,
828
+ } ,
829
+ } ;
830
+
831
+ const compiledResources = [
832
+ {
833
+ type : 'gcp-types/cloudfunctions-v1:projects.locations.functions' ,
834
+ name : 'my-service-dev-func1' ,
835
+ properties : {
836
+ parent : 'projects/myProject/locations/us-central1' ,
837
+ runtime : 'nodejs10' ,
838
+ function : 'my-service-dev-func1' ,
839
+ entryPoint : 'func1' ,
840
+ availableMemoryMb : 128 ,
841
+ timeout : '60s' ,
842
+ sourceArchiveUrl : 'gs://sls-my-service-dev-12345678/some-path/artifact.zip' ,
843
+ httpsTrigger : {
844
+ url : 'foo' ,
845
+ } ,
846
+ labels : { } ,
847
+ vpcConnector : 'projects/pg-us-n-app-123456/locations/us-central1/connectors/my-vpc' ,
848
+ } ,
849
+ } ,
850
+ {
851
+ type : 'gcp-types/cloudfunctions-v1:projects.locations.functions' ,
852
+ name : 'my-service-dev-func2' ,
853
+ properties : {
854
+ parent : 'projects/myProject/locations/us-central1' ,
855
+ runtime : 'nodejs10' ,
856
+ function : 'my-service-dev-func2' ,
857
+ entryPoint : 'func2' ,
858
+ availableMemoryMb : 128 ,
859
+ timeout : '60s' ,
860
+ minInstances : 5 ,
861
+ sourceArchiveUrl : 'gs://sls-my-service-dev-12345678/some-path/artifact.zip' ,
862
+ httpsTrigger : {
863
+ url : 'bar' ,
864
+ } ,
865
+ labels : { } ,
866
+ vpcConnector : 'projects/pg-us-n-app-123456/locations/us-central1/connectors/my-vpc' ,
867
+ } ,
868
+ } ,
869
+ ] ;
870
+
871
+ return googlePackage . compileFunctions ( ) . then ( ( ) => {
872
+ expect ( consoleLogStub . called ) . toEqual ( true ) ;
873
+ expect (
874
+ googlePackage . serverless . service . provider . compiledConfigurationTemplate . resources
875
+ ) . toEqual ( compiledResources ) ;
876
+ } ) ;
877
+ } ) ;
769
878
} ) ;
770
879
771
880
it ( 'should allow vpc as short name' , ( ) => {
0 commit comments