1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

Make .end flush optional and add some tests

This commit is contained in:
Ruben Bridgewater
2015-09-24 13:27:32 +02:00
parent 4b100b8b64
commit bd4fca130d
5 changed files with 48 additions and 6 deletions

View File

@@ -196,6 +196,14 @@ describe("The 'multi' method", function () {
}).exec(done);
});
it('runs a multi without any further commands', function(done) {
client.multi().exec(function(err, res) {
assert.strictEqual(err, null);
assert.strictEqual(res.length, 0);
done();
});
});
it('allows multiple operations to be performed using a chaining API', function (done) {
client.multi()
.mset('some', '10', 'keys', '20')

View File

@@ -174,6 +174,32 @@ describe("The node_redis client", function () {
});
describe(".end", function () {
it('used without flush', function(done) {
var err = null;
client.set('foo', 'bar');
client.end();
client.get('foo', function(err, res) {
err = new Error('failed');
});
setTimeout(function() {
done(err);
}, 200);
});
it('used with flush set to true', function(done) {
client.set('foo', 'bar');
client.end();
client.get('foo', function(err, res) {
assert.strictEqual(err.command, 'GET');
assert.strictEqual(err.message, "GET can't be processed. The connection has already been closed.");
done();
});
});
});
describe("commands after using .quit should fail", function () {
it("return an error in the callback", function (done) {