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

test.js: Switch to pubsub mode when the number of channels is > 0.

Tests for a bug where the client unsubscribes
and then subscribes to a single channel. If the
subscription is sent before the response to the
unsubscribe is received, then the client would
leave pubsub mode when it received the unsubscribe
response and then fail to enter when the subsequent
subscription is processed. This is another test for #190:
https://github.com/mranney/node_redis/pull/190

Signed-off-by: David Trejo <david.daniel.trejo@gmail.com>
This commit is contained in:
Dave Peticolas
2012-02-08 07:56:55 -08:00
committed by David Trejo
parent 172fc8251b
commit 874a893c2c

15
test.js
View File

@@ -582,6 +582,21 @@ tests.SUBSCRIBE = function () {
});
};
tests.SUB_UNSUB_SUB = function () {
var name = "SUB_UNSUB_SUB";
client3.subscribe('chan3');
client3.unsubscribe('chan3');
client3.subscribe('chan3', function (err, results) {
assert.strictEqual(null, err, "unexpected error: " + err);
client2.publish('chan3', 'foo');
});
client3.on('message', function (channel, message) {
assert.strictEqual(channel, 'chan3');
assert.strictEqual(message, 'foo');
next(name);
});
};
tests.SUBSCRIBE_QUIT = function () {
var name = "SUBSCRIBE_QUIT";
client3.on("end", function () {