Skip to content

Commit

Permalink
feat: add custom retry options (#1088)
Browse files Browse the repository at this point in the history
* feat: add custom retry options

* lint

* update test
  • Loading branch information
steffnay committed May 18, 2022
1 parent b49fc4d commit b7f29ed
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/bigquery.ts
Expand Up @@ -326,6 +326,8 @@ export class BigQuery extends Service {
baseUrl,
scopes: ['https://www.googleapis.com/auth/bigquery'],
packageJson: require('../../package.json'),
autoRetry: options.autoRetry,
maxRetries: options.maxRetries,
};

if (options.scopes) {
Expand Down
20 changes: 20 additions & 0 deletions test/bigquery.ts
Expand Up @@ -283,6 +283,26 @@ describe('BigQuery', () => {
assert.deepStrictEqual(calledWith.scopes, expectedScopes);
});

it('should pass autoRetry from options', () => {
const retry = false;
const bq = new BigQuery({
autoRetry: retry,
});

const calledWith = bq.calledWith_[0];
assert.deepStrictEqual(calledWith.autoRetry, retry);
});

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,
Expand Down

0 comments on commit b7f29ed

Please sign in to comment.