Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adjust "non-existen" url in tests #16

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -25,6 +25,7 @@ var options = {
},
json: true, // Automatically parses the JSON string in the response,
retry : 2, // will retry the call twice, in case of error.
logger: myLogger, // custom logger with 'info()' and 'debug()' functions, for example log4js logger
verbose_logging : false, // will log errors only, if set to be true, will log all actions
accepted: [ 400, 404 ] // Accepted HTTP Status codes (will not retry if request response has any of these HTTP Status Code)
delay: 2000 // will delay retries by 2000 ms. The default is 100.
Expand Down
7 changes: 6 additions & 1 deletion index.js
@@ -1,7 +1,8 @@
'use strict';
const requestPromise = require('request-promise');
const Promise = require('bluebird');
const logger = require('./modules/logger')('request-promise-retry');

let logger = require('./modules/logger')('request-promise-retry');

class rpRetry {
static _rpRetry(options) {
Expand Down Expand Up @@ -69,6 +70,10 @@ class rpRetry {
}

static rp(options) {
if (options.logger) {
logger = options.logger;
delete options.logger;
}
if (options.retry) {
if (typeof options.retry === 'number') {
if (options.retry < 0) {
Expand Down
8 changes: 4 additions & 4 deletions test/index.test.js
Expand Up @@ -2,12 +2,12 @@

const rp = require('../index');
const optionsWithRetryFail = {
uri: 'http://adadadadad.com/',
uri: 'http://thisurlshouldnevereverexist.com/',
method: 'GET',
retry: 3
};
const optionsWithoutRetryFail = {
uri: 'http://adadadadad.com/',
uri: 'http://thisurlshouldnevereverexist.com/',
method: 'GET'
};
const optionsWithRetry = {
Expand Down Expand Up @@ -118,7 +118,7 @@ describe('request-promise-retry', function () {
// failure should take a bit of time to happen
const startTime = new Date();
return rp({
uri: 'http://adadadadad.com/',
uri: 'http://thisurlshouldnevereverexist.com/',
method: 'GET',
retry: 4,
delay: 30,
Expand All @@ -139,4 +139,4 @@ describe('request-promise-retry', function () {
return Promise.resolve(expect(data.accepted).equal(false));
});
});
});
});