You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
Merge branch 'jeffbski-0.8.2-unsub-empty'
This commit is contained in:
6
index.js
6
index.js
@@ -634,10 +634,12 @@ RedisClient.prototype.return_reply = function (reply) {
|
|||||||
}
|
}
|
||||||
// subscribe commands take an optional callback and also emit an event, but only the first response is included in the callback
|
// subscribe commands take an optional callback and also emit an event, but only the first response is included in the callback
|
||||||
// TODO - document this or fix it so it works in a more obvious way
|
// TODO - document this or fix it so it works in a more obvious way
|
||||||
|
// reply[1] can be null
|
||||||
|
var reply1String = (reply[1] === null) ? null : reply[1].toString();
|
||||||
if (command_obj && typeof command_obj.callback === "function") {
|
if (command_obj && typeof command_obj.callback === "function") {
|
||||||
try_callback(command_obj.callback, reply[1].toString());
|
try_callback(command_obj.callback, reply1String);
|
||||||
}
|
}
|
||||||
this.emit(type, reply[1].toString(), reply[2]); // channel, count
|
this.emit(type, reply1String, reply[2]); // channel, count
|
||||||
} else {
|
} else {
|
||||||
throw new Error("subscriptions are active but got unknown reply type " + type);
|
throw new Error("subscriptions are active but got unknown reply type " + type);
|
||||||
}
|
}
|
||||||
|
44
test.js
44
test.js
@@ -899,6 +899,50 @@ tests.SUBSCRIBE = function () {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
tests.UNSUB_EMPTY = function () {
|
||||||
|
// test situation where unsubscribe reply[1] is null
|
||||||
|
var name = "UNSUB_EMPTY";
|
||||||
|
client3.unsubscribe(); // unsubscribe from all so can test null
|
||||||
|
client3.unsubscribe(); // reply[1] will be null
|
||||||
|
next(name);
|
||||||
|
};
|
||||||
|
|
||||||
|
tests.PUNSUB_EMPTY = function () {
|
||||||
|
// test situation where punsubscribe reply[1] is null
|
||||||
|
var name = "PUNSUB_EMPTY";
|
||||||
|
client3.punsubscribe(); // punsubscribe from all so can test null
|
||||||
|
client3.punsubscribe(); // reply[1] will be null
|
||||||
|
next(name);
|
||||||
|
};
|
||||||
|
|
||||||
|
tests.UNSUB_EMPTY_CB = function () {
|
||||||
|
var name = "UNSUB_EMPTY_CB";
|
||||||
|
// test hangs on older versions of redis, so skip
|
||||||
|
if (!server_version_at_least(client, [2, 6, 11])) return next(name);
|
||||||
|
|
||||||
|
// test situation where unsubscribe reply[1] is null
|
||||||
|
client3.unsubscribe(); // unsubscribe from all so can test null
|
||||||
|
client3.unsubscribe(function (err, results) {
|
||||||
|
// reply[1] will be null
|
||||||
|
assert.strictEqual(null, err, "unexpected error: " + err);
|
||||||
|
next(name);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
tests.PUNSUB_EMPTY_CB = function () {
|
||||||
|
var name = "PUNSUB_EMPTY_CB";
|
||||||
|
// test hangs on older versions of redis, so skip
|
||||||
|
if (!server_version_at_least(client, [2, 6, 11])) return next(name);
|
||||||
|
|
||||||
|
// test situation where punsubscribe reply[1] is null
|
||||||
|
client3.punsubscribe(); // punsubscribe from all so can test null
|
||||||
|
client3.punsubscribe(function (err, results) {
|
||||||
|
// reply[1] will be null
|
||||||
|
assert.strictEqual(null, err, "unexpected error: " + err);
|
||||||
|
next(name);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
tests.SUB_UNSUB_SUB = function () {
|
tests.SUB_UNSUB_SUB = function () {
|
||||||
var name = "SUB_UNSUB_SUB";
|
var name = "SUB_UNSUB_SUB";
|
||||||
client3.subscribe('chan3');
|
client3.subscribe('chan3');
|
||||||
|
Reference in New Issue
Block a user