You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
Fix inconsistent command argument handling
Earlier multi.command and client.command diverged a lot in the way they accepted arguments. This is now consistent This will also fix some bugs like using multi.hmset with arrays
This commit is contained in:
@@ -58,36 +58,50 @@ describe("The 'flushdb' method", function () {
|
||||
describe("when there is data in Redis", function () {
|
||||
|
||||
beforeEach(function (done) {
|
||||
var end = helper.callFuncAfter(function () {
|
||||
client.flushdb(helper.isString("OK", done));
|
||||
}, 2);
|
||||
client.mset(key, uuid.v4(), key2, uuid.v4(), helper.isNotError(end));
|
||||
client.mset(key, uuid.v4(), key2, uuid.v4(), helper.isNotError());
|
||||
client.dbsize([], function (err, res) {
|
||||
helper.isType.positiveNumber()(err, res);
|
||||
assert.equal(res, 2, 'Two keys should have been inserted');
|
||||
end();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("deletes all the keys", function (done) {
|
||||
client.mget(key, key2, function (err, res) {
|
||||
assert.strictEqual(null, err, "Unexpected error returned");
|
||||
assert.strictEqual(true, Array.isArray(res), "Results object should be an array.");
|
||||
assert.strictEqual(2, res.length, "Results array should have length 2.");
|
||||
assert.strictEqual(null, res[0], "Redis key should have been flushed.");
|
||||
assert.strictEqual(null, res[1], "Redis key should have been flushed.");
|
||||
done(err);
|
||||
client.flushdb(function(err, res) {
|
||||
assert.equal(res, 'OK');
|
||||
client.mget(key, key2, function (err, res) {
|
||||
assert.strictEqual(null, err, "Unexpected error returned");
|
||||
assert.strictEqual(true, Array.isArray(res), "Results object should be an array.");
|
||||
assert.strictEqual(2, res.length, "Results array should have length 2.");
|
||||
assert.strictEqual(null, res[0], "Redis key should have been flushed.");
|
||||
assert.strictEqual(null, res[1], "Redis key should have been flushed.");
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("results in a db size of zero", function (done) {
|
||||
client.dbsize([], function (err, res) {
|
||||
helper.isNotError()(err, res);
|
||||
helper.isType.number()(err, res);
|
||||
assert.strictEqual(0, res, "Flushing db should result in db size 0");
|
||||
done();
|
||||
client.flushdb(function(err, res) {
|
||||
client.dbsize([], function (err, res) {
|
||||
helper.isNotError()(err, res);
|
||||
helper.isType.number()(err, res);
|
||||
assert.strictEqual(0, res, "Flushing db should result in db size 0");
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("results in a db size of zero without a callback", function (done) {
|
||||
client.flushdb();
|
||||
setTimeout(function(err, res) {
|
||||
client.dbsize([], function (err, res) {
|
||||
helper.isNotError()(err, res);
|
||||
helper.isType.number()(err, res);
|
||||
assert.strictEqual(0, res, "Flushing db should result in db size 0");
|
||||
done();
|
||||
});
|
||||
}, 25);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user