@@ -133,7 +133,7 @@ describe('CompileFunctions', () => {
133
133
} ) ;
134
134
} ) ;
135
135
136
- it ( 'should set the environment variables based on the provider configuration' , ( ) => {
136
+ it ( 'should set the memory size based on the provider configuration' , ( ) => {
137
137
googlePackage . serverless . service . functions = {
138
138
func1 : {
139
139
handler : 'func1' ,
@@ -142,9 +142,7 @@ describe('CompileFunctions', () => {
142
142
] ,
143
143
} ,
144
144
} ;
145
- googlePackage . serverless . service . provider . environment = {
146
- TEST_VAR : 'test' ,
147
- } ;
145
+ googlePackage . serverless . service . provider . memorySize = 1024 ;
148
146
149
147
const compiledResources = [ {
150
148
type : 'cloudfunctions.v1beta2.function' ,
@@ -153,10 +151,7 @@ describe('CompileFunctions', () => {
153
151
location : 'us-central1' ,
154
152
runtime : 'nodejs8' ,
155
153
function : 'func1' ,
156
- availableMemoryMb : 256 ,
157
- environmentVariables : {
158
- TEST_VAR : 'test' ,
159
- } ,
154
+ availableMemoryMb : 1024 ,
160
155
timeout : '60s' ,
161
156
sourceArchiveUrl : 'gs://sls-my-service-dev-12345678/some-path/artifact.zip' ,
162
157
httpsTrigger : {
@@ -173,16 +168,16 @@ describe('CompileFunctions', () => {
173
168
} ) ;
174
169
} ) ;
175
170
176
- it ( 'should set the memory size based on the provider configuration' , ( ) => {
171
+ it ( 'should set the timout based on the functions configuration' , ( ) => {
177
172
googlePackage . serverless . service . functions = {
178
173
func1 : {
179
174
handler : 'func1' ,
175
+ timeout : '120s' ,
180
176
events : [
181
177
{ http : 'foo' } ,
182
178
] ,
183
179
} ,
184
180
} ;
185
- googlePackage . serverless . service . provider . memorySize = 1024 ;
186
181
187
182
const compiledResources = [ {
188
183
type : 'cloudfunctions.v1beta2.function' ,
@@ -191,8 +186,8 @@ describe('CompileFunctions', () => {
191
186
location : 'us-central1' ,
192
187
runtime : 'nodejs8' ,
193
188
function : 'func1' ,
194
- availableMemoryMb : 1024 ,
195
- timeout : '60s ' ,
189
+ availableMemoryMb : 256 ,
190
+ timeout : '120s ' ,
196
191
sourceArchiveUrl : 'gs://sls-my-service-dev-12345678/some-path/artifact.zip' ,
197
192
httpsTrigger : {
198
193
url : 'foo' ,
@@ -208,16 +203,16 @@ describe('CompileFunctions', () => {
208
203
} ) ;
209
204
} ) ;
210
205
211
- it ( 'should set the timout based on the functions configuration' , ( ) => {
206
+ it ( 'should set the timeout based on the provider configuration' , ( ) => {
212
207
googlePackage . serverless . service . functions = {
213
208
func1 : {
214
209
handler : 'func1' ,
215
- timeout : '120s' ,
216
210
events : [
217
211
{ http : 'foo' } ,
218
212
] ,
219
213
} ,
220
214
} ;
215
+ googlePackage . serverless . service . provider . timeout = '120s' ;
221
216
222
217
const compiledResources = [ {
223
218
type : 'cloudfunctions.v1beta2.function' ,
@@ -243,16 +238,18 @@ describe('CompileFunctions', () => {
243
238
} ) ;
244
239
} ) ;
245
240
246
- it ( 'should set the timeout based on the provider configuration' , ( ) => {
241
+ it ( 'should set the labels based on the functions configuration' , ( ) => {
247
242
googlePackage . serverless . service . functions = {
248
243
func1 : {
249
244
handler : 'func1' ,
245
+ labels : {
246
+ test : 'label' ,
247
+ } ,
250
248
events : [
251
249
{ http : 'foo' } ,
252
250
] ,
253
251
} ,
254
252
} ;
255
- googlePackage . serverless . service . provider . timeout = '120s' ;
256
253
257
254
const compiledResources = [ {
258
255
type : 'cloudfunctions.v1beta2.function' ,
@@ -262,12 +259,14 @@ describe('CompileFunctions', () => {
262
259
runtime : 'nodejs8' ,
263
260
function : 'func1' ,
264
261
availableMemoryMb : 256 ,
265
- timeout : '120s ' ,
262
+ timeout : '60s ' ,
266
263
sourceArchiveUrl : 'gs://sls-my-service-dev-12345678/some-path/artifact.zip' ,
267
264
httpsTrigger : {
268
265
url : 'foo' ,
269
266
} ,
270
- labels : { } ,
267
+ labels : {
268
+ test : 'label' ,
269
+ } ,
271
270
} ,
272
271
} ] ;
273
272
@@ -278,18 +277,18 @@ describe('CompileFunctions', () => {
278
277
} ) ;
279
278
} ) ;
280
279
281
- it ( 'should set the labels based on the functions configuration' , ( ) => {
280
+ it ( 'should set the labels based on the provider configuration' , ( ) => {
282
281
googlePackage . serverless . service . functions = {
283
282
func1 : {
284
283
handler : 'func1' ,
285
- labels : {
286
- test : 'label' ,
287
- } ,
288
284
events : [
289
285
{ http : 'foo' } ,
290
286
] ,
291
287
} ,
292
288
} ;
289
+ googlePackage . serverless . service . provider . labels = {
290
+ test : 'label' ,
291
+ } ;
293
292
294
293
const compiledResources = [ {
295
294
type : 'cloudfunctions.v1beta2.function' ,
@@ -317,17 +316,21 @@ describe('CompileFunctions', () => {
317
316
} ) ;
318
317
} ) ;
319
318
320
- it ( 'should set the labels based on the provider configuration' , ( ) => {
319
+ it ( 'should set the labels based on the merged provider and function configuration' , ( ) => {
321
320
googlePackage . serverless . service . functions = {
322
321
func1 : {
323
322
handler : 'func1' ,
324
323
events : [
325
324
{ http : 'foo' } ,
326
325
] ,
326
+ labels : {
327
+ test : 'functionLabel' ,
328
+ } ,
327
329
} ,
328
330
} ;
329
331
googlePackage . serverless . service . provider . labels = {
330
- test : 'label' ,
332
+ test : 'providerLabel' ,
333
+ secondTest : 'tested' ,
331
334
} ;
332
335
333
336
const compiledResources = [ {
@@ -344,7 +347,8 @@ describe('CompileFunctions', () => {
344
347
url : 'foo' ,
345
348
} ,
346
349
labels : {
347
- test : 'label' ,
350
+ test : 'functionLabel' ,
351
+ secondTest : 'tested' ,
348
352
} ,
349
353
} ,
350
354
} ] ;
@@ -356,21 +360,57 @@ describe('CompileFunctions', () => {
356
360
} ) ;
357
361
} ) ;
358
362
359
- it ( 'should set the labels based on the merged provider and function configuration' , ( ) => {
363
+ it ( 'should set the environment variables based on the function configuration' , ( ) => {
360
364
googlePackage . serverless . service . functions = {
361
365
func1 : {
362
366
handler : 'func1' ,
367
+ environment : {
368
+ TEST_VAR : 'test' ,
369
+ } ,
363
370
events : [
364
371
{ http : 'foo' } ,
365
372
] ,
366
- labels : {
367
- test : 'functionLabel' ,
373
+ }
374
+ } ;
375
+
376
+ const compiledResources = [ {
377
+ type : 'cloudfunctions.v1beta2.function' ,
378
+ name : 'my-service-dev-func1' ,
379
+ properties : {
380
+ location : 'us-central1' ,
381
+ runtime : 'nodejs8' ,
382
+ function : 'func1' ,
383
+ availableMemoryMb : 256 ,
384
+ environmentVariables : {
385
+ TEST_VAR : 'test' ,
368
386
} ,
387
+ timeout : '60s' ,
388
+ sourceArchiveUrl : 'gs://sls-my-service-dev-12345678/some-path/artifact.zip' ,
389
+ httpsTrigger : {
390
+ url : 'foo' ,
391
+ } ,
392
+ labels : { } ,
393
+ } ,
394
+ } ] ;
395
+
396
+ return googlePackage . compileFunctions ( ) . then ( ( ) => {
397
+ expect ( consoleLogStub . calledOnce ) . toEqual ( true ) ;
398
+ expect ( googlePackage . serverless . service . provider . compiledConfigurationTemplate . resources )
399
+ . toEqual ( compiledResources ) ;
400
+ } ) ;
401
+ } ) ;
402
+
403
+ it ( 'should set the environment variables based on the provider configuration' , ( ) => {
404
+ googlePackage . serverless . service . functions = {
405
+ func1 : {
406
+ handler : 'func1' ,
407
+ events : [
408
+ { http : 'foo' } ,
409
+ ] ,
369
410
} ,
370
411
} ;
371
- googlePackage . serverless . service . provider . labels = {
372
- test : 'providerLabel' ,
373
- secondTest : 'tested' ,
412
+ googlePackage . serverless . service . provider . environment = {
413
+ TEST_VAR : 'test' ,
374
414
} ;
375
415
376
416
const compiledResources = [ {
@@ -381,15 +421,15 @@ describe('CompileFunctions', () => {
381
421
runtime : 'nodejs8' ,
382
422
function : 'func1' ,
383
423
availableMemoryMb : 256 ,
424
+ environmentVariables : {
425
+ TEST_VAR : 'test' ,
426
+ } ,
384
427
timeout : '60s' ,
385
428
sourceArchiveUrl : 'gs://sls-my-service-dev-12345678/some-path/artifact.zip' ,
386
429
httpsTrigger : {
387
430
url : 'foo' ,
388
431
} ,
389
- labels : {
390
- test : 'functionLabel' ,
391
- secondTest : 'tested' ,
392
- } ,
432
+ labels : { } ,
393
433
} ,
394
434
} ] ;
395
435
0 commit comments