Skip to content

Commit ff5d5eb

Browse files
committed
Restore fake timers to connection retry test
1 parent cb546b1 commit ff5d5eb

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

test/integration/connection-retry-test.js

+8
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ exports['connection retry tests'] = {
7474
const config = getConfig();
7575
config.options.connectTimeout = config.options.connectionRetryInterval / 2;
7676

77+
const clock = this.sinon.useFakeTimers('setTimeout');
78+
7779
test.expect(1);
7880

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

91+
connection.on('errorMessage', () => {
92+
// Forward clock past connectTimeout which is less than retry interval.
93+
clock.tick(config.options.connectTimeout + 1);
94+
});
95+
8996
connection.on('connect', (err) => {
9097
test.ok(err);
9198
});
9299

93100
connection.on('end', (info) => {
101+
clock.restore();
94102
test.done();
95103
});
96104
},

0 commit comments

Comments
 (0)