From 2ed0a9d5e036896c969a16f9add6394b304b4f43 Mon Sep 17 00:00:00 2001 From: steffnay Date: Sun, 20 Mar 2022 09:44:26 -0700 Subject: [PATCH 1/3] feat: add custom retry options --- src/bigquery.ts | 3 +++ test/bigquery.ts | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/bigquery.ts b/src/bigquery.ts index f232fb52..d2501091 100644 --- a/src/bigquery.ts +++ b/src/bigquery.ts @@ -326,6 +326,9 @@ export class BigQuery extends Service { baseUrl, scopes: ['https://www.googleapis.com/auth/bigquery'], packageJson: require('../../package.json'), + autoRetry: options.autoRetry, + maxRetries: options.maxRetries, + // what if we pass in retryOptions.maxRetries, retryOptions.autoRetry }; if (options.scopes) { diff --git a/test/bigquery.ts b/test/bigquery.ts index 2432d37a..e0190c42 100644 --- a/test/bigquery.ts +++ b/test/bigquery.ts @@ -273,6 +273,25 @@ describe('BigQuery', () => { assert.deepStrictEqual(calledWith.scopes, expectedScopes); }); + it('should pass autoRetry from options', () => { + const bq = new BigQuery({ + autoRetry: false, + }); + + const calledWith = bq.calledWith_[0]; + assert.deepStrictEqual(calledWith.autoRetry, false); + }); + + it('should pass maxRetries from options', () => { + const retryVal = 1; + const bq = new BigQuery({ + maxRetries: retryVal, + }); + + const calledWith = bq.calledWith_[0]; + assert.deepStrictEqual(calledWith.maxRetries, retryVal); + }); + it('should not modify options argument', () => { const options = { projectId: PROJECT_ID, From e8bcd2a0148bc14d096b8717ad5ba4060522930b Mon Sep 17 00:00:00 2001 From: steffnay Date: Sun, 20 Mar 2022 09:45:45 -0700 Subject: [PATCH 2/3] lint --- src/bigquery.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/bigquery.ts b/src/bigquery.ts index d2501091..2c5804af 100644 --- a/src/bigquery.ts +++ b/src/bigquery.ts @@ -328,7 +328,6 @@ export class BigQuery extends Service { packageJson: require('../../package.json'), autoRetry: options.autoRetry, maxRetries: options.maxRetries, - // what if we pass in retryOptions.maxRetries, retryOptions.autoRetry }; if (options.scopes) { From a8fcf27c011192a9c275c70f3e52d6fe84fd2e5a Mon Sep 17 00:00:00 2001 From: steffnay Date: Sun, 20 Mar 2022 09:47:01 -0700 Subject: [PATCH 3/3] update test --- test/bigquery.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/bigquery.ts b/test/bigquery.ts index e0190c42..78aeaf32 100644 --- a/test/bigquery.ts +++ b/test/bigquery.ts @@ -274,12 +274,13 @@ describe('BigQuery', () => { }); it('should pass autoRetry from options', () => { + const retry = false; const bq = new BigQuery({ - autoRetry: false, + autoRetry: retry, }); const calledWith = bq.calledWith_[0]; - assert.deepStrictEqual(calledWith.autoRetry, false); + assert.deepStrictEqual(calledWith.autoRetry, retry); }); it('should pass maxRetries from options', () => {