1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-07 13:22:56 +03:00

Do not emit the broken mode twice if exec is called

Add more tests
This commit is contained in:
Ruben Bridgewater
2015-09-13 00:27:50 +02:00
parent 30ec1cd6a2
commit 89c8dd056b
4 changed files with 79 additions and 17 deletions

View File

@@ -19,9 +19,7 @@ describe("on lost connection", function () {
var calls = 0;
client.once('ready', function() {
// Pretend that redis can't reconnect
client.on_connect = client.on_error;
client.stream.destroy();
helper.killConnection(client);
});
client.on("reconnecting", function (params) {
@@ -40,16 +38,14 @@ describe("on lost connection", function () {
it("emit an error after max retry timeout and do not try to reconnect afterwards", function (done) {
var connect_timeout = 1000; // in ms
client = redis.createClient({
var client = redis.createClient({
parser: parser,
connect_timeout: connect_timeout
});
var time = 0;
client.once('ready', function() {
// Pretend that redis can't reconnect
client.on_connect = client.on_error;
client.stream.destroy();
helper.killConnection(client);
});
client.on("reconnecting", function (params) {
@@ -66,6 +62,23 @@ describe("on lost connection", function () {
});
});
it("end connection while retry is still ongoing", function (done) {
var connect_timeout = 1000; // in ms
var client = redis.createClient({
parser: parser,
connect_timeout: connect_timeout
});
client.once('ready', function() {
helper.killConnection(client);
});
client.on("reconnecting", function (params) {
client.end();
setTimeout(done, 100);
});
});
});
});
});