You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
chore: improve coverage
This commit is contained in:
@@ -71,6 +71,14 @@ describe('The \'client\' method', () => {
|
||||
promises.push(client.get('foo').then(helper.isString('bar')))
|
||||
return Promise.all(promises)
|
||||
})
|
||||
|
||||
it('weird', function () {
|
||||
helper.serverVersionAtLeast.call(this, client, [3, 2, 0])
|
||||
assert.strictEqual(client._reply, 'ON')
|
||||
const promise = client.client('REPLY', 'WEIRD').then(helper.fail, helper.isError())
|
||||
assert.strictEqual(client._reply, 'ON')
|
||||
return promise
|
||||
})
|
||||
})
|
||||
|
||||
describe('in a batch context', () => {
|
||||
@@ -112,6 +120,14 @@ describe('The \'client\' method', () => {
|
||||
assert.deepStrictEqual(res, ['OK', undefined, undefined, 'bar'])
|
||||
})
|
||||
})
|
||||
|
||||
it('weird', function () {
|
||||
helper.serverVersionAtLeast.call(this, client, [3, 2, 0])
|
||||
assert.strictEqual(client._reply, 'ON')
|
||||
const promise = client.batch().client('REPLY', 'WEIRD').exec().then(helper.fail, helper.isError())
|
||||
assert.strictEqual(client._reply, 'ON')
|
||||
return promise
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
@@ -413,6 +413,20 @@ describe('connection tests', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('connects correctly even if the info command returns a empty string', (done) => {
|
||||
client = Redis.createClient.apply(null, args)
|
||||
const end = helper.callFuncAfter(done, 2)
|
||||
client.info = function () {
|
||||
// Mock the result
|
||||
end()
|
||||
return Promise.resolve('')
|
||||
}
|
||||
client.once('ready', () => {
|
||||
assert.strictEqual(Object.keys(client.serverInfo).length, 0)
|
||||
end()
|
||||
})
|
||||
})
|
||||
|
||||
if (ip === 'IPv4') {
|
||||
it('allows connecting with the redis url to the default host and port, select db 3 and warn about duplicate db option', (done) => {
|
||||
client = Redis.createClient('redis:///3?db=3')
|
||||
|
@@ -198,9 +198,12 @@ describe('The \'multi\' method', () => {
|
||||
client = redis.createClient({
|
||||
host: 'somewhere',
|
||||
port: 6379,
|
||||
family: 'IPv6',
|
||||
retryStrategy () {}
|
||||
})
|
||||
|
||||
assert.strictEqual(client._connectionOptions.family, 6)
|
||||
|
||||
client.on('error', (err) => {
|
||||
assert.strictEqual(err.code, 'NR_CLOSED')
|
||||
done()
|
||||
|
@@ -57,6 +57,26 @@ describe('The nodeRedis client', () => {
|
||||
client._stream.destroy()
|
||||
})
|
||||
|
||||
describe('arguments validation', () => {
|
||||
it('no boolean for enableOfflineQueue', () => {
|
||||
try {
|
||||
redis.createClient({ enableOfflineQueue: 'test' })
|
||||
throw new Error('failed')
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.name, 'TypeError')
|
||||
}
|
||||
})
|
||||
|
||||
it('no boolean for enableOfflineQueue', () => {
|
||||
try {
|
||||
redis.createClient({ password: 'test', authPass: 'foobar' })
|
||||
throw new Error('failed')
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.name, 'TypeError')
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
helper.allTests((ip, args) => {
|
||||
describe(`using ${ip}`, () => {
|
||||
afterEach(() => {
|
||||
@@ -69,6 +89,22 @@ describe('The nodeRedis client', () => {
|
||||
return client.flushdb()
|
||||
})
|
||||
|
||||
describe('argument errors', () => {
|
||||
it('should return an error in case of "null" argument', () => {
|
||||
return client.set('foo', null).then(helper.fail, (err) => {
|
||||
assert.deepStrictEqual(err.issues, [null])
|
||||
})
|
||||
})
|
||||
|
||||
it('should return an error in case of unknown types', () => {
|
||||
class Foo {}
|
||||
const tmp = new Foo()
|
||||
return client.set(tmp, undefined).then(helper.fail, (err) => {
|
||||
assert.deepStrictEqual(err.issues, [tmp, undefined])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('duplicate', () => {
|
||||
it('check if all options got copied properly', (done) => {
|
||||
client.selectedDb = 2
|
||||
|
Reference in New Issue
Block a user