You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
failing tests for empty unsub and punsub
When unsubscribe or punsubscribe is called and there is nothing to unsubscribe from, the reply[1] argument is a null which causes a TypeError Cannot call method 'toString' of null ``` TypeError: Cannot call method 'toString' of null at RedisClient.return_reply (/Users/barczewskij/projects/node_redis/index.js:633:65) at ReplyParser.RedisClient.init_parser (/Users/barczewskij/projects/node_redis/index.js:266:14) at ReplyParser.EventEmitter.emit (events.js:96:17) at ReplyParser.send_reply (/Users/barczewskij/projects/node_redis/lib/parser/javascript.js:300:10) at ReplyParser.execute (/Users/barczewskij/projects/node_redis/lib/parser/javascript.js:211:22) at RedisClient.on_data (/Users/barczewskij/projects/node_redis/index.js:483:27) at Socket.<anonymous> (/Users/barczewskij/projects/node_redis/index.js:82:14) at Socket.EventEmitter.emit (events.js:96:17) at TCP.onread (net.js:396:14) ```
This commit is contained in:
40
test.js
40
test.js
@@ -614,7 +614,7 @@ tests.detect_buffers = function () {
|
|||||||
assert.strictEqual("<Buffer 76 61 6c 20 31>", reply[0].inspect(), name);
|
assert.strictEqual("<Buffer 76 61 6c 20 31>", reply[0].inspect(), name);
|
||||||
assert.strictEqual("<Buffer 76 61 6c 20 32>", reply[1].inspect(), name);
|
assert.strictEqual("<Buffer 76 61 6c 20 32>", reply[1].inspect(), name);
|
||||||
});
|
});
|
||||||
|
|
||||||
// array of strings with undefined values (repro #344)
|
// array of strings with undefined values (repro #344)
|
||||||
detect_client.hmget("hash key 2", "key 3", "key 4", function(err, reply) {
|
detect_client.hmget("hash key 2", "key 3", "key 4", function(err, reply) {
|
||||||
assert.strictEqual(null, err, name);
|
assert.strictEqual(null, err, name);
|
||||||
@@ -864,6 +864,44 @@ 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 () {
|
||||||
|
// test situation where unsubscribe reply[1] is null
|
||||||
|
var name = "UNSUB_EMPTY_CB";
|
||||||
|
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 () {
|
||||||
|
// test situation where punsubscribe reply[1] is null
|
||||||
|
var name = "PUNSUB_EMPTY_CB";
|
||||||
|
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