File tree Expand file tree Collapse file tree 2 files changed +27
-5
lines changed Expand file tree Collapse file tree 2 files changed +27
-5
lines changed Original file line number Diff line number Diff line change @@ -126,10 +126,7 @@ class Job extends Operation {
126
126
options ?: QueryResultsOptions
127
127
) => ResourceStream < RowMetadata > ;
128
128
constructor ( bigQuery : BigQuery , id : string , options ?: JobOptions ) {
129
- let location ;
130
- if ( options && options . location ) {
131
- location = options . location ;
132
- }
129
+ let location : string ;
133
130
134
131
const methods = {
135
132
/**
@@ -222,7 +219,11 @@ class Job extends Operation {
222
219
*/
223
220
getMetadata : {
224
221
reqOpts : {
225
- qs : { location} ,
222
+ qs : {
223
+ get location ( ) {
224
+ return location ;
225
+ } ,
226
+ } ,
226
227
} ,
227
228
} ,
228
229
} ;
@@ -234,6 +235,15 @@ class Job extends Operation {
234
235
methods,
235
236
} ) ;
236
237
238
+ Object . defineProperty ( this , 'location' , {
239
+ get ( ) {
240
+ return location ;
241
+ } ,
242
+ set ( _location ) {
243
+ location = _location ;
244
+ } ,
245
+ } ) ;
246
+
237
247
this . bigQuery = bigQuery ;
238
248
239
249
if ( options && options . location ) {
Original file line number Diff line number Diff line change @@ -150,6 +150,18 @@ describe('BigQuery/Job', () => {
150
150
} ,
151
151
} ) ;
152
152
} ) ;
153
+
154
+ it ( 'should update the location after initializing job object' , ( ) => {
155
+ const job = new Job ( BIGQUERY , JOB_ID ) ;
156
+ job . location = LOCATION ;
157
+ const calledWith = job . calledWith_ [ 0 ] ;
158
+
159
+ assert . deepStrictEqual ( calledWith . methods . getMetadata , {
160
+ reqOpts : {
161
+ qs : { location : LOCATION } ,
162
+ } ,
163
+ } ) ;
164
+ } ) ;
153
165
} ) ;
154
166
155
167
describe ( 'cancel' , ( ) => {
You can’t perform that action at this time.
0 commit comments