Skip to content

Commit

Permalink
Close GH-1: Fix tests and add 'ENOTFOUND' to default errorCodes..
Browse files Browse the repository at this point in the history
  • Loading branch information
ericsaboia authored and satazor committed Nov 27, 2013
1 parent f8800d7 commit 2fcf67c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
3 changes: 2 additions & 1 deletion index.js
Expand Up @@ -6,7 +6,8 @@ var errorCodes = [
'EADDRINFO',
'ETIMEDOUT',
'ECONNRESET',
'ESOCKETTIMEDOUT'
'ESOCKETTIMEDOUT',
'ENOTFOUND'
];

function mixIn(dst, src) {
Expand Down
10 changes: 4 additions & 6 deletions test/test.js
Expand Up @@ -9,11 +9,10 @@ describe('request-replay', function () {
it('should replay on network error', function (next) {
replay(request.get('http://somedomainthatwillneverexistforsure.com:8089', function (error) {
expect(error).to.be.an(Error);
expect(error.code).to.equal('ENOTFOUND');
expect(['ENOTFOUND', 'EADDRINFO']).to.contain(error.code);
expect(error.replays).to.equal(5);
next();
}), {
errorCodes: ['ENOTFOUND'],
factor: 1,
minTimeout: 10,
maxTimeout: 10
Expand All @@ -29,7 +28,7 @@ describe('request-replay', function () {
expect(body).to.eql({ 'foo': 'bar' });
next();
}), {
errorCodes: ['ENOTFOUND', 'ECONNREFUSED']
errorCodes: ['ECONNREFUSED']
})
.on('replay', function () {
http.createServer(function (req, res) {
Expand All @@ -46,11 +45,10 @@ describe('request-replay', function () {

stream = replay(request.get('http://somedomainthatwillneverexistforsure.com:8089', function (error) {
expect(error).to.be.an(Error);
expect(error.code).to.equal('ENOTFOUND');
expect(['ENOTFOUND', 'EADDRINFO']).to.contain(error.code);
expect(error.replays).to.equal(5);
next();
}), {
errorCodes: ['ENOTFOUND'],
factor: 1,
minTimeout: 10,
maxTimeout: 10,
Expand All @@ -60,7 +58,7 @@ describe('request-replay', function () {
expect(replay).to.be.an('object');
expect(replay.number).to.equal(tries);
expect(replay.error).to.be.an(Error);
expect(replay.error.code).to.equal('ENOTFOUND');
expect(['ENOTFOUND', 'EADDRINFO']).to.contain(replay.error.code);
expect(replay.delay).to.be(10);
tries++;
});
Expand Down

0 comments on commit 2fcf67c

Please sign in to comment.