1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

ensure client emits connect and end events

This commit is contained in:
rick
2010-09-20 12:29:35 -07:00
parent 68f540ad54
commit 0b51924aa7
2 changed files with 13 additions and 1 deletions

View File

@@ -390,7 +390,7 @@ RedisClient.prototype.connection_gone = function () {
console.warn("Redis connection is gone."); console.warn("Redis connection is gone.");
} }
self.connected = false; self.connected = false;
self.emit("close"); self.emit("end");
self.command_queue.forEach(function (args) { self.command_queue.forEach(function (args) {
if (typeof args[2] === "function") { if (typeof args[2] === "function") {
args[2]("Server connection closed"); args[2]("Server connection closed");

12
test.js
View File

@@ -374,11 +374,18 @@ function run_next_test() {
} }
} }
var connected = false;
var ended = false;
client.on("connect", function () { client.on("connect", function () {
connected = true;
console.log(); console.log();
run_next_test(); run_next_test();
}); });
client.on('end', function() {
ended = true;
});
client.on("error", function (err) { client.on("error", function (err) {
console.log("Redis clent connection failed."); console.log("Redis clent connection failed.");
}); });
@@ -390,3 +397,8 @@ client.on("reconnecting", function (msg) {
process.on('uncaughtException', function (err) { process.on('uncaughtException', function (err) {
console.log("Uncaught exception: " + err.stack); console.log("Uncaught exception: " + err.stack);
}); });
process.on('exit', function(code) {
assert.equal(true, connected);
assert.equal(true, ended);
});