1
0
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:
Jeff Barczewski
2013-03-26 10:26:12 -05:00
parent 3aab43e55a
commit 0c143a7299

38
test.js
View File

@@ -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 () {
var name = "SUB_UNSUB_SUB";
client3.subscribe('chan3');