Skip to content

Commit 359820c

Browse files
author
Ruben Bridgewater
committed
Support redis 2.4 info command
Fixes #1008
1 parent eb9500b commit 359820c

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

lib/individualCommands.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ RedisClient.prototype.select = RedisClient.prototype.SELECT = function select (d
3737
RedisClient.prototype.info = RedisClient.prototype.INFO = function info (section, callback) {
3838
var self = this;
3939
var ready = this.ready;
40+
var args = [];
4041
if (typeof section === 'function') {
4142
callback = section;
42-
section = 'default';
43-
} else if (section === undefined) {
44-
section = 'default';
43+
} else if (section !== undefined) {
44+
args = Array.isArray(section) ? section : [section];
4545
}
4646
this.ready = ready || this.offline_queue.length === 0; // keep the execution order intakt
47-
var tmp = this.send_command('info', [section], function (err, res) {
47+
var tmp = this.send_command('info', args, function (err, res) {
4848
if (res) {
4949
var obj = {};
5050
var lines = res.toString().split('\r\n');

test/commands/info.spec.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ describe("The 'info' method", function () {
1212
describe("using " + parser + " and " + ip, function () {
1313
var client;
1414

15-
before(function (done) {
15+
beforeEach(function (done) {
1616
client = redis.createClient.apply(null, args);
1717
client.once("ready", function () {
1818
client.flushall(done);
1919
});
2020
});
2121

22-
after(function () {
22+
afterEach(function () {
2323
client.end(true);
2424
});
2525

@@ -41,9 +41,10 @@ describe("The 'info' method", function () {
4141
client.set('foo', 'bar');
4242
client.info('keyspace');
4343
client.select(2, function () {
44-
assert.strictEqual(Object.keys(client.server_info).length, 3, 'Key length should be three');
45-
assert(typeof client.server_info.db2 === 'object', 'db2 keyspace should be an object');
44+
assert.strictEqual(Object.keys(client.server_info).length, 2, 'Key length should be three');
45+
assert.strictEqual(typeof client.server_info.db0, 'object', 'db0 keyspace should be an object');
4646
});
47+
client.info(['keyspace']);
4748
client.set('foo', 'bar');
4849
client.info('all', function (err, res) {
4950
assert(Object.keys(client.server_info).length > 3, 'Key length should be way above three');
@@ -53,6 +54,17 @@ describe("The 'info' method", function () {
5354
});
5455
});
5556

57+
it('check redis v.2.4 support', function (done) {
58+
var end = helper.callFuncAfter(done, 2);
59+
client.send_command = function (command, args, callback) {
60+
assert.strictEqual(args.length, 0);
61+
assert.strictEqual(command, 'info');
62+
end();
63+
};
64+
client.info();
65+
client.info(function () {});
66+
});
67+
5668
it("emit error after a failure", function (done) {
5769
client.info();
5870
client.once('error', function (err) {

0 commit comments

Comments
 (0)