Skip to content

Commit

Permalink
fixed wrong codes and revised test naming
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-ext-simba-jy committed Sep 22, 2023
1 parent 7069d1c commit bf56e2e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
5 changes: 3 additions & 2 deletions lib/connection/connection_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const DEFAULT_PARAMS =
'arrayBindingThreshold',
'gcsUseDownscopedCredential',
'forceStageBindError',
'includeRetryReason'
'includeRetryReason',
];

function consolidateHostAndAccount(options)
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 () {
Expand Down
2 changes: 1 addition & 1 deletion lib/connection/statement.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};
Expand Down
17 changes: 10 additions & 7 deletions test/unit/util_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
})
}
})

Expand Down

0 comments on commit bf56e2e

Please sign in to comment.