1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-04 15:02:09 +03:00
Files
node-redis/test/commands/info.spec.js
Ruben Bridgewater 2b4ab10305 chore - remove standard and use individual config
Standard is not as up to date and still uses a old eslint version.
Instead, use the airbnb default with a couple of modifications.

All required changes are included.
2017-11-28 21:38:21 -02:00

64 lines
2.1 KiB
JavaScript

'use strict'
const assert = require('assert')
const config = require('../lib/config')
const helper = require('../helper')
const { redis } = config
describe('The \'info\' method', () => {
helper.allTests((ip, args) => {
describe(`using ${ip}`, () => {
let client
beforeEach(() => {
client = redis.createClient.apply(null, args)
return client.flushall()
})
afterEach(() => {
client.end(true)
})
it('update serverInfo after a info command', () => {
client.set('foo', 'bar')
return client.info().then(() => {
assert.strictEqual(client.serverInfo.keyspace.db2, undefined)
client.select(2)
client.set('foo', 'bar')
return client.info().then(() => {
assert.strictEqual(typeof client.serverInfo.keyspace.db2, 'object')
})
})
})
it('works with optional section provided', () => {
client.set('foo', 'bar')
client.info('keyspace')
return client.select(2).then(() => {
assert.strictEqual(Object.keys(client.serverInfo).length, 1, 'Key length should be one')
assert.strictEqual(Object.keys(client.serverInfo.keyspace.db0).length, 3, 'Key length should be three')
assert.strictEqual(typeof client.serverInfo.keyspace.db0, 'object', 'db0 keyspace should be an object')
client.info(['keyspace'])
client.set('foo', 'bar')
return client.info('all').then((res) => {
assert(Object.keys(client.serverInfo).length > 3, 'Key length should be way above three')
assert.strictEqual(typeof client.serverInfo.server.redis_version, 'string')
assert.strictEqual(typeof client.serverInfo.keyspace.db2, 'object')
})
})
})
it('return error after a failure', () => {
client.on('error', helper.isError(/This socket is closed/))
const promise = client.info().then(helper.fail).catch((err) => {
assert.strictEqual(err.code, 'UNCERTAIN_STATE')
assert.strictEqual(err.command, 'INFO')
})
client._stream.destroy()
return promise
})
})
})
})