|
|
@ -188,54 +188,16 @@ describe("The node_redis client", function () { |
|
|
|
// Does not pass.
|
|
|
|
// "Connection in subscriber mode, only subscriber commands may be used"
|
|
|
|
it("reconnects, unsubscribes, and can retrieve the pre-existing data", function (done) { |
|
|
|
client.on("reconnecting", function on_recon(params) { |
|
|
|
client.on("ready", function on_connect() { |
|
|
|
client.unsubscribe(helper.isNotError()); |
|
|
|
|
|
|
|
client.on('unsubscribe', function (channel, count) { |
|
|
|
// we should now be out of subscriber mode.
|
|
|
|
client.set('foo', 'bar', helper.isNumber(1)); |
|
|
|
return done(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
client.on("ready", function on_connect() { |
|
|
|
client.unsubscribe(helper.isNotError()); |
|
|
|
|
|
|
|
client.set("recon 1", "one"); |
|
|
|
client.subscribe("recon channel", function (err, res) { |
|
|
|
// Do not do this in normal programs. This is to simulate the server closing on us.
|
|
|
|
// For orderly shutdown in normal programs, do client.quit()
|
|
|
|
client.stream.destroy(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
it("remains subscribed", function () { |
|
|
|
var client2 = redis.createClient.apply(redis.createClient, args); |
|
|
|
|
|
|
|
client.on("reconnecting", function on_recon(params) { |
|
|
|
client.on("ready", function on_connect() { |
|
|
|
async.parallel([function (cb) { |
|
|
|
client.on("message", function (channel, message) { |
|
|
|
try { |
|
|
|
helper.isString("recon channel")(null, channel); |
|
|
|
helper.isString("a test message")(null, message); |
|
|
|
} catch (err) { |
|
|
|
cb(err); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
client2.subscribe("recon channel", function (err, res) { |
|
|
|
if (err) { |
|
|
|
cb(err); |
|
|
|
return; |
|
|
|
} |
|
|
|
client2.publish("recon channel", "a test message"); |
|
|
|
}); |
|
|
|
}], function (err, results) { |
|
|
|
done(err); |
|
|
|
}); |
|
|
|
client.on('unsubscribe', function (channel, count) { |
|
|
|
// we should now be out of subscriber mode.
|
|
|
|
client.set('foo', 'bar', helper.isString('OK', done)); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
client.set("recon 1", "one"); |
|
|
|
client.subscribe("recon channel", function (err, res) { |
|
|
|
// Do not do this in normal programs. This is to simulate the server closing on us.
|
|
|
|
// For orderly shutdown in normal programs, do client.quit()
|
|
|
|