@@ -96,6 +96,138 @@ describe('CompileFunctions', () => {
9696 expect ( ( ) => googleDeploy . compileFunctions ( ) ) . toThrow ( Error ) ;
9797 } ) ;
9898
99+ it ( 'should set the memory size based on the functions configuration' , ( ) => {
100+ googleDeploy . serverless . service . functions = {
101+ func1 : {
102+ handler : 'func1' ,
103+ memorySize : 1024 ,
104+ events : [
105+ { http : 'foo' } ,
106+ ] ,
107+ } ,
108+ } ;
109+
110+ const compiledResources = [ {
111+ type : 'cloudfunctions.v1beta2.function' ,
112+ name : 'my-service-dev-func1' ,
113+ properties : {
114+ location : 'us-central1' ,
115+ function : 'func1' ,
116+ availableMemoryMb : 1024 ,
117+ timeout : '60s' ,
118+ sourceArchiveUrl : 'gs://sls-my-service-dev/some-path/artifact.zip' ,
119+ httpsTrigger : {
120+ url : 'foo' ,
121+ } ,
122+ } ,
123+ } ] ;
124+
125+ return googleDeploy . compileFunctions ( ) . then ( ( ) => {
126+ expect ( consoleLogStub . calledOnce ) . toEqual ( true ) ;
127+ expect ( googleDeploy . serverless . service . provider . compiledConfigurationTemplate . resources )
128+ . toEqual ( compiledResources ) ;
129+ } ) ;
130+ } ) ;
131+
132+ it ( 'should set the memory size based on the provider configuration' , ( ) => {
133+ googleDeploy . serverless . service . functions = {
134+ func1 : {
135+ handler : 'func1' ,
136+ events : [
137+ { http : 'foo' } ,
138+ ] ,
139+ } ,
140+ } ;
141+ googleDeploy . serverless . service . provider . memorySize = 1024 ;
142+
143+ const compiledResources = [ {
144+ type : 'cloudfunctions.v1beta2.function' ,
145+ name : 'my-service-dev-func1' ,
146+ properties : {
147+ location : 'us-central1' ,
148+ function : 'func1' ,
149+ availableMemoryMb : 1024 ,
150+ timeout : '60s' ,
151+ sourceArchiveUrl : 'gs://sls-my-service-dev/some-path/artifact.zip' ,
152+ httpsTrigger : {
153+ url : 'foo' ,
154+ } ,
155+ } ,
156+ } ] ;
157+
158+ return googleDeploy . compileFunctions ( ) . then ( ( ) => {
159+ expect ( consoleLogStub . calledOnce ) . toEqual ( true ) ;
160+ expect ( googleDeploy . serverless . service . provider . compiledConfigurationTemplate . resources )
161+ . toEqual ( compiledResources ) ;
162+ } ) ;
163+ } ) ;
164+
165+ it ( 'should set the timout based on the functions configuration' , ( ) => {
166+ googleDeploy . serverless . service . functions = {
167+ func1 : {
168+ handler : 'func1' ,
169+ timeout : '120s' ,
170+ events : [
171+ { http : 'foo' } ,
172+ ] ,
173+ } ,
174+ } ;
175+
176+ const compiledResources = [ {
177+ type : 'cloudfunctions.v1beta2.function' ,
178+ name : 'my-service-dev-func1' ,
179+ properties : {
180+ location : 'us-central1' ,
181+ function : 'func1' ,
182+ availableMemoryMb : 256 ,
183+ timeout : '120s' ,
184+ sourceArchiveUrl : 'gs://sls-my-service-dev/some-path/artifact.zip' ,
185+ httpsTrigger : {
186+ url : 'foo' ,
187+ } ,
188+ } ,
189+ } ] ;
190+
191+ return googleDeploy . compileFunctions ( ) . then ( ( ) => {
192+ expect ( consoleLogStub . calledOnce ) . toEqual ( true ) ;
193+ expect ( googleDeploy . serverless . service . provider . compiledConfigurationTemplate . resources )
194+ . toEqual ( compiledResources ) ;
195+ } ) ;
196+ } ) ;
197+
198+ it ( 'should set the timeout based on the provider configuration' , ( ) => {
199+ googleDeploy . serverless . service . functions = {
200+ func1 : {
201+ handler : 'func1' ,
202+ events : [
203+ { http : 'foo' } ,
204+ ] ,
205+ } ,
206+ } ;
207+ googleDeploy . serverless . service . provider . timeout = '120s' ;
208+
209+ const compiledResources = [ {
210+ type : 'cloudfunctions.v1beta2.function' ,
211+ name : 'my-service-dev-func1' ,
212+ properties : {
213+ location : 'us-central1' ,
214+ function : 'func1' ,
215+ availableMemoryMb : 256 ,
216+ timeout : '120s' ,
217+ sourceArchiveUrl : 'gs://sls-my-service-dev/some-path/artifact.zip' ,
218+ httpsTrigger : {
219+ url : 'foo' ,
220+ } ,
221+ } ,
222+ } ] ;
223+
224+ return googleDeploy . compileFunctions ( ) . then ( ( ) => {
225+ expect ( consoleLogStub . calledOnce ) . toEqual ( true ) ;
226+ expect ( googleDeploy . serverless . service . provider . compiledConfigurationTemplate . resources )
227+ . toEqual ( compiledResources ) ;
228+ } ) ;
229+ } ) ;
230+
99231 it ( 'should compile "http" events properly' , ( ) => {
100232 googleDeploy . serverless . service . functions = {
101233 func1 : {
@@ -112,6 +244,8 @@ describe('CompileFunctions', () => {
112244 properties : {
113245 location : 'us-central1' ,
114246 function : 'func1' ,
247+ availableMemoryMb : 256 ,
248+ timeout : '60s' ,
115249 sourceArchiveUrl : 'gs://sls-my-service-dev/some-path/artifact.zip' ,
116250 httpsTrigger : {
117251 url : 'foo' ,
@@ -160,6 +294,8 @@ describe('CompileFunctions', () => {
160294 properties : {
161295 location : 'us-central1' ,
162296 function : 'func1' ,
297+ availableMemoryMb : 256 ,
298+ timeout : '60s' ,
163299 sourceArchiveUrl : 'gs://sls-my-service-dev/some-path/artifact.zip' ,
164300 eventTrigger : {
165301 eventType : 'foo' ,
@@ -174,6 +310,8 @@ describe('CompileFunctions', () => {
174310 properties : {
175311 location : 'us-central1' ,
176312 function : 'func2' ,
313+ availableMemoryMb : 256 ,
314+ timeout : '60s' ,
177315 sourceArchiveUrl : 'gs://sls-my-service-dev/some-path/artifact.zip' ,
178316 eventTrigger : {
179317 eventType : 'foo' ,
0 commit comments