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: mark private variables as such and remove obsolete ones
This commit is contained in:
@@ -72,9 +72,8 @@ if (process.platform !== 'win32') {
|
||||
if (helper.redisProcess().spawnFailed()) this.skip()
|
||||
|
||||
client = redis.createClient(`redis://${config.HOST[ip]}:${config.PORT}?db=2&password=${auth}`)
|
||||
assert.strictEqual(client.options.db, '2')
|
||||
assert.strictEqual(client.options.password, auth)
|
||||
assert.strictEqual(client.authPass, auth)
|
||||
assert.strictEqual(client._options.db, '2')
|
||||
assert.strictEqual(client._options.password, auth)
|
||||
client.on('ready', () => {
|
||||
const promises = []
|
||||
// Set a key so the used database is returned in the info command
|
||||
@@ -209,7 +208,7 @@ if (process.platform !== 'win32') {
|
||||
client = redis.createClient.apply(null, args)
|
||||
client.set('foo', 'bar')
|
||||
client.subscribe('somechannel', 'another channel').then(() => {
|
||||
assert.strictEqual(client.pubSubMode, 1)
|
||||
assert.strictEqual(client._pubSubMode, 1)
|
||||
client.once('ready', () => {
|
||||
client.get('foo').catch((err) => {
|
||||
assert(/ERR only \(P\)SUBSCRIBE \/ \(P\)UNSUBSCRIBE/.test(err.message))
|
||||
@@ -219,7 +218,7 @@ if (process.platform !== 'win32') {
|
||||
})
|
||||
client.once('ready', () => {
|
||||
// Coherent behavior with all other offline commands fires commands before emitting but does not wait till they return
|
||||
assert.strictEqual(client.pubSubMode, 2)
|
||||
assert.strictEqual(client._pubSubMode, 2)
|
||||
client.ping().then(() => { // Make sure all commands were properly processed already
|
||||
client._stream.destroy()
|
||||
})
|
||||
|
@@ -46,27 +46,27 @@ describe('The \'client\' method', () => {
|
||||
describe('as normal command', () => {
|
||||
it('on', function () {
|
||||
helper.serverVersionAtLeast.call(this, client, [3, 2, 0])
|
||||
assert.strictEqual(client.reply, 'ON')
|
||||
assert.strictEqual(client._reply, 'ON')
|
||||
const promises = [client.client('reply', 'on').then(helper.isString('OK'))]
|
||||
assert.strictEqual(client.reply, 'ON')
|
||||
assert.strictEqual(client._reply, 'ON')
|
||||
promises.push(client.set('foo', 'bar'))
|
||||
return Promise.all(promises)
|
||||
})
|
||||
|
||||
it('off', function () {
|
||||
helper.serverVersionAtLeast.call(this, client, [3, 2, 0])
|
||||
assert.strictEqual(client.reply, 'ON')
|
||||
assert.strictEqual(client._reply, 'ON')
|
||||
const promises = [client.client(Buffer.from('REPLY'), 'OFF').then(helper.isUndefined())]
|
||||
assert.strictEqual(client.reply, 'OFF')
|
||||
assert.strictEqual(client._reply, 'OFF')
|
||||
promises.push(client.set('foo', 'bar').then(helper.isUndefined()))
|
||||
return Promise.all(promises)
|
||||
})
|
||||
|
||||
it('skip', function () {
|
||||
helper.serverVersionAtLeast.call(this, client, [3, 2, 0])
|
||||
assert.strictEqual(client.reply, 'ON')
|
||||
assert.strictEqual(client._reply, 'ON')
|
||||
const promises = [client.client('REPLY', Buffer.from('SKIP')).then(helper.isUndefined())]
|
||||
assert.strictEqual(client.reply, 'SKIP_ONE_MORE')
|
||||
assert.strictEqual(client._reply, 'SKIP_ONE_MORE')
|
||||
promises.push(client.set('foo', 'bar').then(helper.isUndefined()))
|
||||
promises.push(client.get('foo').then(helper.isString('bar')))
|
||||
return Promise.all(promises)
|
||||
@@ -77,9 +77,9 @@ describe('The \'client\' method', () => {
|
||||
it('on', function () {
|
||||
helper.serverVersionAtLeast.call(this, client, [3, 2, 0])
|
||||
const batch = client.batch()
|
||||
assert.strictEqual(client.reply, 'ON')
|
||||
assert.strictEqual(client._reply, 'ON')
|
||||
batch.client('reply', 'on')
|
||||
assert.strictEqual(client.reply, 'ON')
|
||||
assert.strictEqual(client._reply, 'ON')
|
||||
batch.set('foo', 'bar')
|
||||
return batch.exec().then(helper.isDeepEqual(['OK', 'OK']))
|
||||
})
|
||||
@@ -87,20 +87,20 @@ describe('The \'client\' method', () => {
|
||||
it('off', function () {
|
||||
helper.serverVersionAtLeast.call(this, client, [3, 2, 0])
|
||||
const batch = client.batch()
|
||||
assert.strictEqual(client.reply, 'ON')
|
||||
assert.strictEqual(client._reply, 'ON')
|
||||
batch.set('hello', 'world')
|
||||
batch.client(Buffer.from('REPLY'), Buffer.from('OFF'))
|
||||
batch.get('hello')
|
||||
batch.get('hello')
|
||||
return batch.exec().then((res) => {
|
||||
assert.strictEqual(client.reply, 'OFF')
|
||||
assert.strictEqual(client._reply, 'OFF')
|
||||
assert.deepStrictEqual(res, ['OK', undefined, undefined, undefined])
|
||||
})
|
||||
})
|
||||
|
||||
it('skip', function () {
|
||||
helper.serverVersionAtLeast.call(this, client, [3, 2, 0])
|
||||
assert.strictEqual(client.reply, 'ON')
|
||||
assert.strictEqual(client._reply, 'ON')
|
||||
return client.batch()
|
||||
.set('hello', 'world')
|
||||
.client('REPLY', 'SKIP')
|
||||
@@ -108,7 +108,7 @@ describe('The \'client\' method', () => {
|
||||
.get('foo')
|
||||
.exec()
|
||||
.then((res) => {
|
||||
assert.strictEqual(client.reply, 'ON')
|
||||
assert.strictEqual(client._reply, 'ON')
|
||||
assert.deepStrictEqual(res, ['OK', undefined, undefined, 'bar'])
|
||||
})
|
||||
})
|
||||
|
@@ -62,7 +62,7 @@ describe('The \'monitor\' method', () => {
|
||||
})
|
||||
|
||||
monitorClient.on('monitor', (time, args, rawOutput) => {
|
||||
assert.strictEqual(monitorClient.monitoring, true)
|
||||
assert.strictEqual(monitorClient._monitoring, true)
|
||||
assert.deepStrictEqual(args, responses.shift())
|
||||
assert(utils.monitorRegex.test(rawOutput), rawOutput)
|
||||
if (responses.length === 0) {
|
||||
@@ -81,7 +81,7 @@ describe('The \'monitor\' method', () => {
|
||||
})
|
||||
|
||||
monitorClient.monitor().then((res) => {
|
||||
assert.strictEqual(monitorClient.monitoring, true)
|
||||
assert.strictEqual(monitorClient._monitoring, true)
|
||||
assert.strictEqual(res.inspect(), Buffer.from('OK').inspect())
|
||||
monitorClient.mget('hello', Buffer.from('world'))
|
||||
})
|
||||
@@ -100,7 +100,7 @@ describe('The \'monitor\' method', () => {
|
||||
client.monitor().then(helper.isString('OK'))
|
||||
client.mget('hello', 'world')
|
||||
client.on('monitor', (time, args, rawOutput) => {
|
||||
assert.strictEqual(client.monitoring, true)
|
||||
assert.strictEqual(client._monitoring, true)
|
||||
assert(utils.monitorRegex.test(rawOutput), rawOutput)
|
||||
assert.deepStrictEqual(args, ['mget', 'hello', 'world'])
|
||||
if (called) {
|
||||
@@ -120,7 +120,7 @@ describe('The \'monitor\' method', () => {
|
||||
multi.mget('hello', 'world')
|
||||
multi.exec().then(helper.isDeepEqual(['OK', [null, null]]))
|
||||
client.on('monitor', (time, args, rawOutput) => {
|
||||
assert.strictEqual(client.monitoring, true)
|
||||
assert.strictEqual(client._monitoring, true)
|
||||
assert(utils.monitorRegex.test(rawOutput), rawOutput)
|
||||
assert.deepStrictEqual(args, ['mget', 'hello', 'world'])
|
||||
if (called) {
|
||||
@@ -141,12 +141,12 @@ describe('The \'monitor\' method', () => {
|
||||
client._stream.destroy()
|
||||
const end = helper.callFuncAfter(done, 2)
|
||||
client.on('monitor', (time, args, rawOutput) => {
|
||||
assert.strictEqual(client.monitoring, true)
|
||||
assert.strictEqual(client._monitoring, true)
|
||||
end()
|
||||
})
|
||||
client.on('reconnecting', () => {
|
||||
client.get('foo').then((res) => {
|
||||
assert.strictEqual(client.monitoring, true)
|
||||
assert.strictEqual(client._monitoring, true)
|
||||
end()
|
||||
})
|
||||
})
|
||||
|
@@ -23,8 +23,9 @@ describe('connection tests', () => {
|
||||
// Therefore this is not officially supported!
|
||||
const socket = new net.Socket()
|
||||
client = new redis.RedisClient({
|
||||
prefix: 'test'
|
||||
}, socket)
|
||||
prefix: 'test',
|
||||
stream: socket
|
||||
})
|
||||
assert.strictEqual(client._stream, socket)
|
||||
assert.strictEqual(client._stream.listeners('error').length, 1)
|
||||
assert.strictEqual(client.address, '"Private stream"')
|
||||
@@ -160,7 +161,7 @@ describe('connection tests', () => {
|
||||
retryStrategy () {}
|
||||
}
|
||||
client = redis.createClient(options)
|
||||
assert.strictEqual(client.connectionOptions.family, ip === 'IPv6' ? 6 : 4)
|
||||
assert.strictEqual(client._connectionOptions.family, ip === 'IPv6' ? 6 : 4)
|
||||
assert.strictEqual(Object.keys(options).length, 4)
|
||||
const end = helper.callFuncAfter(done, 2)
|
||||
|
||||
@@ -246,7 +247,7 @@ describe('connection tests', () => {
|
||||
})
|
||||
process.nextTick(() => assert.strictEqual(client._stream.listeners('timeout').length, 1))
|
||||
assert.strictEqual(client.address, '10.255.255.1:6379')
|
||||
assert.strictEqual(client.connectionOptions.family, 4)
|
||||
assert.strictEqual(client._connectionOptions.family, 4)
|
||||
|
||||
client.on('reconnecting', () => {
|
||||
throw new Error('No reconnect, since no connection was ever established')
|
||||
@@ -274,7 +275,7 @@ describe('connection tests', () => {
|
||||
host: '2001:db8::ff00:42:8329' // auto detect ip v6
|
||||
})
|
||||
assert.strictEqual(client.address, '2001:db8::ff00:42:8329:6379')
|
||||
assert.strictEqual(client.connectionOptions.family, 6)
|
||||
assert.strictEqual(client._connectionOptions.family, 6)
|
||||
process.nextTick(() => {
|
||||
assert.strictEqual(client._stream.listeners('timeout').length, 0)
|
||||
done()
|
||||
@@ -337,7 +338,7 @@ describe('connection tests', () => {
|
||||
|
||||
it('connects with a port only', (done) => {
|
||||
client = redis.createClient(6379)
|
||||
assert.strictEqual(client.connectionOptions.family, 4)
|
||||
assert.strictEqual(client._connectionOptions.family, 4)
|
||||
client.on('error', done)
|
||||
|
||||
client.once('ready', () => {
|
||||
@@ -433,7 +434,7 @@ describe('connection tests', () => {
|
||||
client = redis.createClient('//127.0.0.1', {
|
||||
connectTimeout: 1000
|
||||
})
|
||||
assert.strictEqual(client.options.connectTimeout, 1000)
|
||||
assert.strictEqual(client._options.connectTimeout, 1000)
|
||||
client.on('ready', done)
|
||||
})
|
||||
|
||||
@@ -441,10 +442,10 @@ describe('connection tests', () => {
|
||||
client = redis.createClient({
|
||||
url: `http://foo:porkchopsandwiches@${config.HOST[ip]}/3`
|
||||
})
|
||||
assert.strictEqual(client.authPass, 'porkchopsandwiches')
|
||||
assert.strictEqual(client._options.password, 'porkchopsandwiches')
|
||||
assert.strictEqual(+client.selectedDb, 3)
|
||||
assert(!client.options.port)
|
||||
assert.strictEqual(client.options.host, config.HOST[ip])
|
||||
assert(!client._options.port)
|
||||
assert.strictEqual(client._options.host, config.HOST[ip])
|
||||
client.on('ready', done)
|
||||
})
|
||||
|
||||
|
@@ -201,7 +201,7 @@ module.exports = {
|
||||
},
|
||||
killConnection (client) {
|
||||
// Change the connection option to a non existing one and destroy the stream
|
||||
client.connectionOptions = {
|
||||
client._connectionOptions = {
|
||||
port: 65535,
|
||||
host: '127.0.0.1',
|
||||
family: 4
|
||||
|
@@ -77,9 +77,9 @@ describe('The nodeRedis client', () => {
|
||||
assert.strictEqual(client2.selectedDb, 2)
|
||||
assert(client.connected)
|
||||
assert(!client2.connected)
|
||||
for (const elem in client.options) {
|
||||
if (client.options.hasOwnProperty(elem)) {
|
||||
assert.strictEqual(client2.options[elem], client.options[elem])
|
||||
for (const elem in client._options) {
|
||||
if (client._options.hasOwnProperty(elem)) {
|
||||
assert.strictEqual(client2._options[elem], client._options[elem])
|
||||
}
|
||||
}
|
||||
client2.on('error', (err) => {
|
||||
@@ -101,13 +101,13 @@ describe('The nodeRedis client', () => {
|
||||
})
|
||||
assert(client.connected)
|
||||
assert(!client2.connected)
|
||||
assert.strictEqual(client.options.noReadyCheck, undefined)
|
||||
assert.strictEqual(client2.options.noReadyCheck, true)
|
||||
assert.notDeepEqual(client.options, client2.options)
|
||||
for (const elem in client.options) {
|
||||
if (client.options.hasOwnProperty(elem)) {
|
||||
assert.strictEqual(client._options.noReadyCheck, undefined)
|
||||
assert.strictEqual(client2._options.noReadyCheck, true)
|
||||
assert.notDeepEqual(client._options, client2._options)
|
||||
for (const elem in client._options) {
|
||||
if (client._options.hasOwnProperty(elem)) {
|
||||
if (elem !== 'noReadyCheck') {
|
||||
assert.strictEqual(client2.options[elem], client.options[elem])
|
||||
assert.strictEqual(client2._options[elem], client._options[elem])
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -331,17 +331,17 @@ describe('The nodeRedis client', () => {
|
||||
it('reconnects properly when monitoring', (done) => {
|
||||
client.on('reconnecting', function onRecon (params) {
|
||||
client.on('ready', function onReady () {
|
||||
assert.strictEqual(client.monitoring, true, 'monitoring after reconnect')
|
||||
assert.strictEqual(client._monitoring, true, 'monitoring after reconnect')
|
||||
client.removeListener('ready', onReady)
|
||||
client.removeListener('reconnecting', onRecon)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
assert.strictEqual(client.monitoring, false, 'monitoring off at start')
|
||||
assert.strictEqual(client._monitoring, false, 'monitoring off at start')
|
||||
client.set('recon 1', 'one')
|
||||
client.monitor().then((res) => {
|
||||
assert.strictEqual(client.monitoring, true, 'monitoring on after monitor()')
|
||||
assert.strictEqual(client._monitoring, true, 'monitoring on after monitor()')
|
||||
client.set('recon 2', 'two').then((res) => {
|
||||
// Do not do this in normal programs. This is to simulate the server closing on us.
|
||||
// For orderly shutdown in normal programs, do client.quit()
|
||||
|
@@ -77,7 +77,7 @@ describe('publish/subscribe', () => {
|
||||
assert.strictEqual(typeof count, 'number')
|
||||
assert.strictEqual(--i, count)
|
||||
if (count === 0) {
|
||||
assert.deepStrictEqual(sub.subscriptionSet, {})
|
||||
assert.deepStrictEqual(sub._subscriptionSet, {})
|
||||
end()
|
||||
}
|
||||
})
|
||||
|
@@ -20,7 +20,7 @@ describe('returnBuffers', () => {
|
||||
let i = 1
|
||||
if (args[2].detectBuffers) {
|
||||
// Test if detectBuffer option was deactivated
|
||||
assert.strictEqual(client.options.detectBuffers, false)
|
||||
assert.strictEqual(client._options.detectBuffers, false)
|
||||
args[2].detectBuffers = false
|
||||
i++
|
||||
}
|
||||
|
@@ -76,7 +76,7 @@ describe('TLS connection tests', () => {
|
||||
assert.strictEqual(client.emittedEnd, true)
|
||||
assert.strictEqual(client.connected, false)
|
||||
assert.strictEqual(client.ready, false)
|
||||
assert.strictEqual(client.closing, true)
|
||||
assert.strictEqual(client._closing, true)
|
||||
assert.strictEqual(time, connectTimeout)
|
||||
done()
|
||||
})
|
||||
@@ -97,8 +97,8 @@ describe('TLS connection tests', () => {
|
||||
})
|
||||
|
||||
// verify connection is using TCP, not UNIX socket
|
||||
assert.strictEqual(client.connectionOptions.host, 'localhost')
|
||||
assert.strictEqual(client.connectionOptions.port, tlsPort)
|
||||
assert.strictEqual(client._connectionOptions.host, 'localhost')
|
||||
assert.strictEqual(client._connectionOptions.port, tlsPort)
|
||||
assert.strictEqual(client.address, `localhost:${tlsPort}`)
|
||||
assert(client._stream.encrypted)
|
||||
|
||||
|
Reference in New Issue
Block a user