You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-04 15:02:09 +03:00
Implement CLIENT REPLY ON|OFF|SKIP
This commit is contained in:
@ -30,25 +30,89 @@ describe("The 'client' method", function () {
|
||||
});
|
||||
|
||||
it("lists connected clients when invoked with multi's chaining syntax", function (done) {
|
||||
client.multi().client('list').exec(function (err, results) {
|
||||
assert(pattern.test(results[0]), "expected string '" + results + "' to match " + pattern.toString());
|
||||
return done();
|
||||
});
|
||||
client.multi().client('list', helper.isType.string()).exec(helper.match(pattern, done));
|
||||
});
|
||||
|
||||
it('lists connected clients when invoked with array syntax on client', function (done) {
|
||||
client.multi().client(['list']).exec(function (err, results) {
|
||||
assert(pattern.test(results[0]), "expected string '" + results + "' to match " + pattern.toString());
|
||||
return done();
|
||||
});
|
||||
client.multi().client(['list']).exec(helper.match(pattern, done));
|
||||
});
|
||||
|
||||
it("lists connected clients when invoked with multi's array syntax", function (done) {
|
||||
client.multi([
|
||||
['client', 'list']
|
||||
]).exec(function (err, results) {
|
||||
assert(pattern.test(results[0]), "expected string '" + results + "' to match " + pattern.toString());
|
||||
return done();
|
||||
]).exec(helper.match(pattern, done));
|
||||
});
|
||||
});
|
||||
|
||||
describe('reply', function () {
|
||||
describe('as normal command', function () {
|
||||
it('on', function (done) {
|
||||
helper.serverVersionAtLeast.call(this, client, [3, 2, 0]);
|
||||
assert.strictEqual(client.reply, 'ON');
|
||||
client.client('reply', 'on', helper.isString('OK'));
|
||||
assert.strictEqual(client.reply, 'ON');
|
||||
client.set('foo', 'bar', done);
|
||||
});
|
||||
|
||||
it('off', function (done) {
|
||||
helper.serverVersionAtLeast.call(this, client, [3, 2, 0]);
|
||||
assert.strictEqual(client.reply, 'ON');
|
||||
client.client(new Buffer('REPLY'), 'OFF', helper.isUndefined());
|
||||
assert.strictEqual(client.reply, 'OFF');
|
||||
client.set('foo', 'bar', helper.isUndefined(done));
|
||||
});
|
||||
|
||||
it('skip', function (done) {
|
||||
helper.serverVersionAtLeast.call(this, client, [3, 2, 0]);
|
||||
assert.strictEqual(client.reply, 'ON');
|
||||
client.client('REPLY', new Buffer('SKIP'), helper.isUndefined());
|
||||
assert.strictEqual(client.reply, 'SKIP_ONE_MORE');
|
||||
client.set('foo', 'bar', helper.isUndefined());
|
||||
client.get('foo', helper.isString('bar', done));
|
||||
});
|
||||
});
|
||||
|
||||
describe('in a batch context', function () {
|
||||
it('on', function (done) {
|
||||
helper.serverVersionAtLeast.call(this, client, [3, 2, 0]);
|
||||
var batch = client.batch();
|
||||
assert.strictEqual(client.reply, 'ON');
|
||||
batch.client('reply', 'on', helper.isString('OK'));
|
||||
assert.strictEqual(client.reply, 'ON');
|
||||
batch.set('foo', 'bar');
|
||||
batch.exec(function (err, res) {
|
||||
assert.deepEqual(res, ['OK', 'OK']);
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
|
||||
it('off', function (done) {
|
||||
helper.serverVersionAtLeast.call(this, client, [3, 2, 0]);
|
||||
var batch = client.batch();
|
||||
assert.strictEqual(client.reply, 'ON');
|
||||
batch.set('hello', 'world');
|
||||
batch.client(new Buffer('REPLY'), new Buffer('OFF'), helper.isUndefined());
|
||||
batch.set('foo', 'bar', helper.isUndefined());
|
||||
batch.exec(function (err, res) {
|
||||
assert.strictEqual(client.reply, 'OFF');
|
||||
assert.deepEqual(res, ['OK', undefined, undefined]);
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
|
||||
it('skip', function (done) {
|
||||
helper.serverVersionAtLeast.call(this, client, [3, 2, 0]);
|
||||
assert.strictEqual(client.reply, 'ON');
|
||||
client.batch()
|
||||
.set('hello', 'world')
|
||||
.client('REPLY', 'SKIP', helper.isUndefined())
|
||||
.set('foo', 'bar', helper.isUndefined())
|
||||
.get('foo')
|
||||
.exec(function (err, res) {
|
||||
assert.strictEqual(client.reply, 'ON');
|
||||
assert.deepEqual(res, ['OK', undefined, undefined, 'bar']);
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user