You've already forked node-redis
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:
@@ -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')
|
||||
|
@@ -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) {
|
||||
|
Reference in New Issue
Block a user