From bf56e2ec45d0bbb525409ab607d50419f8180646 Mon Sep 17 00:00:00 2001 From: sfc-gh-ext-simba-jy Date: Fri, 22 Sep 2023 00:52:33 -0700 Subject: [PATCH] fixed wrong codes and revised test naming --- lib/connection/connection_config.js | 5 +++-- lib/connection/statement.js | 2 +- lib/util.js | 3 ++- test/unit/util_test.js | 17 ++++++++++------- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/lib/connection/connection_config.js b/lib/connection/connection_config.js index daa8fc4bd..88b777094 100644 --- a/lib/connection/connection_config.js +++ b/lib/connection/connection_config.js @@ -49,7 +49,7 @@ const DEFAULT_PARAMS = 'arrayBindingThreshold', 'gcsUseDownscopedCredential', 'forceStageBindError', - 'includeRetryReason' + 'includeRetryReason', ]; function consolidateHostAndAccount(options) @@ -489,6 +489,7 @@ function ConnectionConfig(options, validateCredentials, qaMode, clientInfo) if (Util.exists(options.includeRetryReason)) { Errors.checkArgumentValid(Util.isBoolean(options.includeRetryReason), ErrorCodes.ERR_CONN_CREATE_INVALID_INCLUDE_RETRY_REASON); + includeRetryReason = options.includeRetryReason; } @@ -758,7 +759,7 @@ function ConnectionConfig(options, validateCredentials, qaMode, clientInfo) /** * Returns whether the Retry reason is included or not in the retry url * - * @returns {string} + * @returns {Boolean} */ this.getIncludeRetryReason = function () { diff --git a/lib/connection/statement.js b/lib/connection/statement.js index 1e1e3ce8d..1376d5037 100644 --- a/lib/connection/statement.js +++ b/lib/connection/statement.js @@ -1575,7 +1575,7 @@ function sendSfRequest(statementContext, options, appendQueryParamOnRetry) url: urlOrig, retryCount: numRetries, retryReason: lastStatusCodeForRetry, - includeRetryContext: connectionConfig.getIncludeRetryContext() + includeRetryReason: connectionConfig.getIncludeRetryReason(), } options.url = Util.url.appendRetryParam(retryOption); diff --git a/lib/util.js b/lib/util.js index 3ebb3bd12..8c822b4f1 100644 --- a/lib/util.js +++ b/lib/util.js @@ -348,9 +348,10 @@ exports.url = appendRetryParam: function (option) { let retryUrl = this.appendParam(option.url, 'retryCount', option.retryCount); - if (option.includeRetryContext) { + if (option.includeRetryReason) { retryUrl = this.appendParam(retryUrl, 'retryReason', option.retryReason); } + return retryUrl; } }; diff --git a/test/unit/util_test.js b/test/unit/util_test.js index d0852ae1c..6a0e11e57 100644 --- a/test/unit/util_test.js +++ b/test/unit/util_test.js @@ -488,34 +488,37 @@ describe('Util', function () } }); - it('Util.url.appendRetryParam()', function () { - let url; + describe('Append retry parameters', function () { const testCases = [ { + testName: "test appending retry params with retry reason", option: { url: 'http://www.something.snowflakecomputing.com', retryCount: 3, retryReason: 429, - includeRetryContext: true, + includeRetryReason: true, }, result: 'http://www.something.snowflakecomputing.com?retryCount=3&retryReason=429' }, { + testName: "test appending retry params without retry reason", option: { url: 'http://www.something.snowflakecomputing.com', retryCount: 3, retryReason: 429, - includeRetryContext: false, + includeRetryReason: false, }, result: 'http://www.something.snowflakecomputing.com?retryCount=3' } ]; for (let i = 0; i < testCases.length; i++) { - testCase = testCases[i]; - url = Util.url.appendRetryParam(testCase.option); - assert.strictEqual(url, testCase.result); + const testCase = testCases[i]; + it(testCase.testName, function () { + const url = Util.url.appendRetryParam(testCase.option); + assert.strictEqual(url, testCase.result); + }) } })