@@ -146,7 +146,7 @@ describe('params reached to function', () => {
146
146
) . toBe ( true )
147
147
} )
148
148
149
- test ( 'invoke mirror with invoke header and valid region' , async ( ) => {
149
+ test ( 'invoke mirror set valid region on request ' , async ( ) => {
150
150
/**
151
151
* @feature headers
152
152
*/
@@ -230,7 +230,7 @@ describe('params reached to function', () => {
230
230
) . toBe ( true )
231
231
} )
232
232
233
- test ( 'invoke with region overrides region in the client ' , async ( ) => {
233
+ test ( 'starts client with default region, invoke reverts to any (no x-region header) ' , async ( ) => {
234
234
/**
235
235
* @feature headers
236
236
*/
@@ -248,6 +248,7 @@ describe('params reached to function', () => {
248
248
'custom-header' : customHeader ,
249
249
Authorization : `Bearer ${ apiKey } ` ,
250
250
} ,
251
+ region : FunctionRegion . Any
251
252
} )
252
253
253
254
log ( 'assert no error' )
@@ -268,32 +269,31 @@ describe('params reached to function', () => {
268
269
console . log ( data ?. headers )
269
270
expect (
270
271
( data ?. headers as [ Array < string > ] ) . filter ( ( [ k , v ] ) => k === 'x-region' && v === validRegion )
271
- . length > 0
272
+ . length == 0
272
273
) . toBe ( true )
273
274
} )
274
275
275
- test ( 'invoke mirror with invoke header and valid region ' , async ( ) => {
276
+ test ( 'invoke region set only on the constructor ' , async ( ) => {
276
277
/**
277
278
* @feature headers
278
279
*/
279
280
log ( 'create FunctionsClient' )
280
- const fclient = new FunctionsClient ( `http://localhost:${ relay . container . getMappedPort ( 8081 ) } ` )
281
+ const fclient = new FunctionsClient ( `http://localhost:${ relay . container . getMappedPort ( 8081 ) } ` , { region : FunctionRegion . ApNortheast1 } )
281
282
282
283
log ( 'invoke mirror' )
283
284
const customHeader = nanoid ( )
284
- const validRegion = FunctionRegion . EuWest1
285
+
285
286
286
287
const { data, error } = await fclient . invoke < MirrorResponse > ( 'mirror' , {
287
288
headers : {
288
289
'custom-header' : customHeader ,
289
- Authorization : `Bearer ${ apiKey } ` ,
290
- 'x-region' : validRegion ,
290
+ Authorization : `Bearer ${ apiKey } `
291
291
} ,
292
292
} )
293
293
294
294
log ( 'assert no error' )
295
295
expect (
296
- ( data ?. headers as [ Array < string > ] ) . filter ( ( [ k , v ] ) => k === 'x-region' && v === FunctionRegion . EuWest1 )
296
+ ( data ?. headers as [ Array < string > ] ) . filter ( ( [ k , v ] ) => k === 'x-region' && v === FunctionRegion . ApNortheast1 )
297
297
. length > 0
298
298
) . toBe ( true )
299
299
} )
0 commit comments