forked from redis/node-redis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
info.spec.js
79 lines (69 loc) · 2.95 KB
/
info.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
'use strict';
var assert = require('assert');
var config = require('../lib/config');
var helper = require('../helper');
var redis = config.redis;
describe("The 'info' method", function () {
helper.allTests(function (ip, args) {
describe('using ' + ip, function () {
var client;
beforeEach(function (done) {
client = redis.createClient.apply(null, args);
client.once('ready', function () {
client.flushall(done);
});
});
afterEach(function () {
client.end(true);
});
it('update serverInfo after a info command', function (done) {
client.set('foo', 'bar');
client.info();
client.select(2, function () {
assert.strictEqual(client.serverInfo.db2, undefined);
});
client.set('foo', 'bar');
client.info();
setTimeout(function () {
assert.strictEqual(typeof client.serverInfo.db2, 'object');
done();
}, 30);
});
it('works with optional section provided with and without callback', function (done) {
client.set('foo', 'bar');
client.info('keyspace');
client.select(2, function () {
assert.strictEqual(Object.keys(client.server_info).length, 2, 'Key length should be three');
assert.strictEqual(typeof client.server_info.db0, 'object', 'db0 keyspace should be an object');
});
client.info(['keyspace']);
client.set('foo', 'bar');
client.info('all', function (err, res) {
assert(Object.keys(client.server_info).length > 3, 'Key length should be way above three');
assert.strictEqual(typeof client.server_info.redis_version, 'string');
assert.strictEqual(typeof client.server_info.db2, 'object');
done();
});
});
it('check redis v.2.4 support', function (done) {
var end = helper.callFuncAfter(done, 2);
client.internal_send_command = function (command_obj) {
assert.strictEqual(command_obj.args.length, 0);
assert.strictEqual(command_obj.command, 'info');
end();
};
client.info();
client.info(function () {});
});
it('emit error after a failure', function (done) {
client.info();
client.once('error', function (err) {
assert.strictEqual(err.code, 'UNCERTAIN_STATE');
assert.strictEqual(err.command, 'INFO');
done();
});
client.stream.destroy();
});
});
});
});