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

Fix fired but not yet returned commands not being rejected after a connection loss

This commit is contained in:
Ruben Bridgewater
2015-10-26 21:37:02 +01:00
parent ebea0872a9
commit 0ec2c43603
4 changed files with 154 additions and 47 deletions

View File

@@ -317,6 +317,39 @@ describe("publish/subscribe", function () {
});
});
it("should not publish a message multiple times per command", function (done) {
var published = {};
function subscribe(message) {
sub.removeAllListeners('subscribe');
sub.removeAllListeners('message');
sub.removeAllListeners('unsubscribe');
sub.on('subscribe', function () {
pub.publish('/foo', message);
});
sub.on('message', function (channel, message) {
if (published[message]) {
done(new Error('Message published more than once.'));
}
published[message] = true;
});
sub.on('unsubscribe', function (channel, count) {
assert.strictEqual(count, 0);
});
sub.subscribe('/foo');
}
subscribe('hello');
setTimeout(function () {
sub.unsubscribe();
setTimeout(function () {
subscribe('world');
setTimeout(done, 50);
}, 40);
}, 40);
});
// TODO: Fix pub sub
// And there's more than just those two issues
describe.skip('FIXME: broken pub sub', function () {
@@ -331,35 +364,6 @@ describe("publish/subscribe", function () {
});
setTimeout(done, 200);
});
it("should not publish a message multiple times per command", function (done) {
var published = {};
function subscribe(message) {
sub.on('subscribe', function () {
pub.publish('/foo', message);
});
sub.on('message', function (channel, message) {
if (published[message]) {
done(new Error('Message published more than once.'));
}
published[message] = true;
});
sub.on('unsubscribe', function (channel, count) {
assert.strictEqual(count, 0);
});
sub.subscribe('/foo');
}
subscribe('hello');
setTimeout(function () {
sub.unsubscribe();
setTimeout(function () {
subscribe('world');
}, 40);
}, 40);
});
});
afterEach(function () {