@@ -41,7 +41,7 @@ describe("FunctionBuilder", () => {
41
41
. auth . user ( )
42
42
. onCreate ( ( user ) => user ) ;
43
43
44
- expect ( fn . __endpoint . region ) . to . deep . equal ( [ " us-east1" ] ) ;
44
+ expect ( fn . __trigger . regions ) . to . deep . equal ( [ ' us-east1' ] ) ;
45
45
} ) ;
46
46
47
47
it ( "should allow multiple supported regions to be set" , ( ) => {
@@ -50,7 +50,7 @@ describe("FunctionBuilder", () => {
50
50
. auth . user ( )
51
51
. onCreate ( ( user ) => user ) ;
52
52
53
- expect ( fn . __endpoint . region ) . to . deep . equal ( [ " us-east1" , " us-central1" ] ) ;
53
+ expect ( fn . __trigger . regions ) . to . deep . equal ( [ ' us-east1' , ' us-central1' ] ) ;
54
54
} ) ;
55
55
56
56
it ( "should allow all supported regions to be set" , ( ) => {
@@ -68,15 +68,15 @@ describe("FunctionBuilder", () => {
68
68
. auth . user ( )
69
69
. onCreate ( ( user ) => user ) ;
70
70
71
- expect ( fn . __endpoint . region ) . to . deep . equal ( [
72
- " us-central1" ,
73
- " us-east1" ,
74
- " us-east4" ,
75
- " europe-west1" ,
76
- " europe-west2" ,
77
- " europe-west3" ,
78
- " asia-east2" ,
79
- " asia-northeast1" ,
71
+ expect ( fn . __trigger . regions ) . to . deep . equal ( [
72
+ ' us-central1' ,
73
+ ' us-east1' ,
74
+ ' us-east4' ,
75
+ ' europe-west1' ,
76
+ ' europe-west2' ,
77
+ ' europe-west3' ,
78
+ ' asia-east2' ,
79
+ ' asia-northeast1' ,
80
80
] ) ;
81
81
} ) ;
82
82
@@ -104,13 +104,9 @@ describe("FunctionBuilder", () => {
104
104
. auth . user ( )
105
105
. onCreate ( ( user ) => user ) ;
106
106
107
- expect ( fn . __endpoint . secretEnvironmentVariables ) . to . deep . equal ( [
108
- {
109
- key : "API_KEY" ,
110
- } ,
111
- ] ) ;
112
-
113
- clearParams ( ) ;
107
+ expect ( fn . __trigger . availableMemoryMb ) . to . deep . equal ( 256 ) ;
108
+ expect ( fn . __trigger . timeout ) . to . deep . equal ( '90s' ) ;
109
+ expect ( fn . __trigger . failurePolicy ) . to . deep . equal ( { retry : { } } ) ;
114
110
} ) ;
115
111
116
112
it ( "should apply a default failure policy if it's aliased with `true`" , ( ) => {
@@ -136,9 +132,9 @@ describe("FunctionBuilder", () => {
136
132
. auth . user ( )
137
133
. onCreate ( ( user ) => user ) ;
138
134
139
- expect ( fn . __endpoint . region ) . to . deep . equal ( [ " europe-west2" ] ) ;
140
- expect ( fn . __endpoint . availableMemoryMb ) . to . deep . equal ( 256 ) ;
141
- expect ( fn . __endpoint . timeoutSeconds ) . to . deep . equal ( 90 ) ;
135
+ expect ( fn . __trigger . regions ) . to . deep . equal ( [ ' europe-west2' ] ) ;
136
+ expect ( fn . __trigger . availableMemoryMb ) . to . deep . equal ( 256 ) ;
137
+ expect ( fn . __trigger . timeout ) . to . deep . equal ( '90s' ) ;
142
138
} ) ;
143
139
144
140
it ( "should allow both valid runtime options and supported region to be set in reverse order" , ( ) => {
@@ -151,9 +147,9 @@ describe("FunctionBuilder", () => {
151
147
. auth . user ( )
152
148
. onCreate ( ( user ) => user ) ;
153
149
154
- expect ( fn . __endpoint . region ) . to . deep . equal ( [ " europe-west1" ] ) ;
155
- expect ( fn . __endpoint . availableMemoryMb ) . to . deep . equal ( 256 ) ;
156
- expect ( fn . __endpoint . timeoutSeconds ) . to . deep . equal ( 90 ) ;
150
+ expect ( fn . __trigger . regions ) . to . deep . equal ( [ ' europe-west1' ] ) ;
151
+ expect ( fn . __trigger . availableMemoryMb ) . to . deep . equal ( 256 ) ;
152
+ expect ( fn . __trigger . timeout ) . to . deep . equal ( '90s' ) ;
157
153
} ) ;
158
154
159
155
it ( "should fail if supported region but invalid runtime options are set (reverse order)" , ( ) => {
@@ -223,7 +219,7 @@ describe("FunctionBuilder", () => {
223
219
. runWith ( { ingressSettings : "ALLOW_INTERNAL_ONLY" } )
224
220
. https . onRequest ( ( ) => undefined ) ;
225
221
226
- expect ( fn . __endpoint . ingressSettings ) . to . equal ( " ALLOW_INTERNAL_ONLY" ) ;
222
+ expect ( fn . __trigger . ingressSettings ) . to . equal ( ' ALLOW_INTERNAL_ONLY' ) ;
227
223
} ) ;
228
224
229
225
it ( "should throw an error if user chooses an invalid ingressSettings" , ( ) => {
@@ -245,11 +241,7 @@ describe("FunctionBuilder", () => {
245
241
. auth . user ( )
246
242
. onCreate ( ( user ) => user ) ;
247
243
248
- if ( ! ( fn . __endpoint . vpc instanceof ResetValue ) ) {
249
- expect ( fn . __endpoint . vpc . connector ) . to . equal ( "test-connector" ) ;
250
- } else {
251
- expect . fail ( "__endpoint.vpc unexpectedly set to RESET_VALUE" ) ;
252
- }
244
+ expect ( fn . __trigger . vpcConnector ) . to . equal ( 'test-connector' ) ;
253
245
} ) ;
254
246
255
247
it ( "should allow a vpcConnectorEgressSettings to be set" , ( ) => {
@@ -261,11 +253,9 @@ describe("FunctionBuilder", () => {
261
253
. auth . user ( )
262
254
. onCreate ( ( user ) => user ) ;
263
255
264
- if ( ! ( fn . __endpoint . vpc instanceof ResetValue ) ) {
265
- expect ( fn . __endpoint . vpc . egressSettings ) . to . equal ( "PRIVATE_RANGES_ONLY" ) ;
266
- } else {
267
- expect . fail ( "__endpoint.vpc unexpectedly set to RESET_VALUE" ) ;
268
- }
256
+ expect ( fn . __trigger . vpcConnectorEgressSettings ) . to . equal (
257
+ 'PRIVATE_RANGES_ONLY'
258
+ ) ;
269
259
} ) ;
270
260
271
261
it ( "should throw an error if user chooses an invalid vpcConnectorEgressSettings" , ( ) => {
@@ -294,16 +284,19 @@ describe("FunctionBuilder", () => {
294
284
expect ( fn . __endpoint . serviceAccountEmail ) . to . equal ( serviceAccount ) ;
295
285
} ) ;
296
286
297
- it ( "should allow a serviceAccount to be set with generated service account email" , ( ) => {
298
- const serviceAccount = "test-service-account@" ;
287
+ it ( 'should allow a serviceAccount to be set with generated service account email' , ( ) => {
288
+ const serviceAccount = 'test-service-account@' ;
289
+ const projectId = process . env . GCLOUD_PROJECT ;
299
290
const fn = functions
300
291
. runWith ( {
301
292
serviceAccount,
302
293
} )
303
294
. auth . user ( )
304
295
. onCreate ( ( user ) => user ) ;
305
296
306
- expect ( fn . __endpoint . serviceAccountEmail ) . to . equal ( `test-service-account@` ) ;
297
+ expect ( fn . __trigger . serviceAccountEmail ) . to . equal (
298
+ `test-service-account@${ projectId } .iam.gserviceaccount.com`
299
+ ) ;
307
300
} ) ;
308
301
309
302
it ( "should set a null serviceAccountEmail if service account is set to `default`" , ( ) => {
@@ -315,7 +308,7 @@ describe("FunctionBuilder", () => {
315
308
. auth . user ( )
316
309
. onCreate ( ( user ) => user ) ;
317
310
318
- expect ( fn . __endpoint . serviceAccountEmail ) . to . equal ( "default" ) ;
311
+ expect ( fn . __trigger . serviceAccountEmail ) . to . be . null ;
319
312
} ) ;
320
313
321
314
it ( "should throw an error if serviceAccount is set to an invalid value" , ( ) => {
@@ -349,8 +342,8 @@ describe("FunctionBuilder", () => {
349
342
. auth . user ( )
350
343
. onCreate ( ( user ) => user ) ;
351
344
352
- expect ( fn . __endpoint . labels ) . to . deep . equal ( {
353
- " valid-key" : " valid-value" ,
345
+ expect ( fn . __trigger . labels ) . to . deep . equal ( {
346
+ ' valid-key' : ' valid-value' ,
354
347
} ) ;
355
348
} ) ;
356
349
@@ -504,11 +497,7 @@ describe("FunctionBuilder", () => {
504
497
. auth . user ( )
505
498
. onCreate ( ( user ) => user ) ;
506
499
507
- expect ( fn . __endpoint . secretEnvironmentVariables ) . to . deep . equal ( [
508
- {
509
- key : "API_KEY" ,
510
- } ,
511
- ] ) ;
500
+ expect ( fn . __trigger . secrets ) . to . deep . equal ( secrets ) ;
512
501
} ) ;
513
502
514
503
it ( "should throw error given secrets expressed with full resource name" , ( ) => {
@@ -519,7 +508,9 @@ describe("FunctionBuilder", () => {
519
508
secrets : [ "projects/my-project/secrets/API_KEY" ] ,
520
509
} )
521
510
) . to . throw ( ) ;
511
+ } ) ;
522
512
513
+ it ( 'should throw error given invalid secret config' , ( ) => {
523
514
expect ( ( ) =>
524
515
functions . runWith ( {
525
516
secrets : [ sp ] ,
0 commit comments