You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
* upgrade workflow actions
* fix setup-node version
* change redis-64 version to 3.0.503
* fix "no password is set" for redis6,
fix tests to work with redis6,
add redis6 to workflows
* do not use assert.match (was added only at v13.6.0 & v12.16.0)
* fix errors.subscribeUnsubscribeOnly regex
* fix invaliodPassword typo
* send --save "" to redis-server in tests
* upgrade dependencies, set node minimum version to 10, use current LTS versions in tests and benchmark workflows
* change windows tests too
* revert mocha back to ^4.1.0
* fix for f5528504a0
- revert mocha back to ^4.1.0
* fix some tests and upgrade mocha
* fix two more tests
* try to fix tests in windows
* upgrade denque and redis-commands
ref #1575
* replace `new Buffer` (deprecated) with `Buffer.from`
* Buffer.from(0) should be Buffer.alloc(0)
156 lines
6.6 KiB
JavaScript
156 lines
6.6 KiB
JavaScript
'use strict';
|
|
|
|
var assert = require('assert');
|
|
var config = require('../lib/config');
|
|
var helper = require('../helper');
|
|
var redis = config.redis;
|
|
|
|
describe("The 'client' method", function () {
|
|
|
|
helper.allTests(function (ip, args) {
|
|
var pattern = /addr=/;
|
|
|
|
describe('using ' + ip, function () {
|
|
var client;
|
|
|
|
beforeEach(function (done) {
|
|
client = redis.createClient.apply(null, args);
|
|
client.once('ready', function () {
|
|
client.flushdb(done);
|
|
});
|
|
});
|
|
|
|
afterEach(function () {
|
|
client.end(true);
|
|
});
|
|
|
|
describe('list', function () {
|
|
it('lists connected clients', function (done) {
|
|
client.client('LIST', helper.match(pattern, done));
|
|
});
|
|
|
|
it("lists connected clients when invoked with multi's chaining syntax", function (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(helper.match(pattern, done));
|
|
});
|
|
|
|
it("lists connected clients when invoked with multi's array syntax", function (done) {
|
|
client.multi([
|
|
['client', 'list']
|
|
]).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(Buffer.from('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', Buffer.from('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(Buffer.from('REPLY'), Buffer.from('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);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('setname / getname', function () {
|
|
var client2;
|
|
|
|
beforeEach(function (done) {
|
|
client2 = redis.createClient.apply(null, args);
|
|
client2.once('ready', function () {
|
|
done();
|
|
});
|
|
});
|
|
|
|
afterEach(function () {
|
|
client2.end(true);
|
|
});
|
|
|
|
it('sets the name', function (done) {
|
|
// The querys are auto pipelined and the response is a response to all querys of one client
|
|
// per chunk. So the execution order is only garanteed on each client
|
|
var end = helper.callFuncAfter(done, 2);
|
|
|
|
client.client('setname', 'RUTH');
|
|
client2.client('setname', ['RENEE'], helper.isString('OK'));
|
|
client2.client(['setname', 'MARTIN'], helper.isString('OK'));
|
|
client2.client('getname', function (err, res) {
|
|
assert.equal(res, 'MARTIN');
|
|
end();
|
|
});
|
|
client.client('getname', function (err, res) {
|
|
assert.equal(res, 'RUTH');
|
|
end();
|
|
});
|
|
});
|
|
|
|
});
|
|
});
|
|
});
|
|
});
|