Skip to content

Commit

Permalink
Restore fake timers to connection retry test
Browse files Browse the repository at this point in the history
  • Loading branch information
joux3 committed Jan 22, 2018
1 parent cb546b1 commit ff5d5eb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/integration/connection-retry-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ exports['connection retry tests'] = {
const config = getConfig();
config.options.connectTimeout = config.options.connectionRetryInterval / 2;

const clock = this.sinon.useFakeTimers('setTimeout');

test.expect(1);

this.sinon.stub(TransientErrorLookup.prototype, 'isTransientError', (error) => {
Expand All @@ -86,11 +88,17 @@ exports['connection retry tests'] = {
test.ok(false);
});

connection.on('errorMessage', () => {
// Forward clock past connectTimeout which is less than retry interval.
clock.tick(config.options.connectTimeout + 1);
});

connection.on('connect', (err) => {
test.ok(err);
});

connection.on('end', (info) => {
clock.restore();
test.done();
});
},
Expand Down

0 comments on commit ff5d5eb

Please sign in to comment.