You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
chore: improve coverage further
This commit is contained in:
@@ -103,7 +103,7 @@ Multi.prototype.quit = function quit () {
|
||||
this._client._closing = true
|
||||
this._client.ready = false
|
||||
}
|
||||
this._queue.push(new Command('quit', [], null, quitCallback(this._client), callOnWrite))
|
||||
this._queue.push(new Command('quit', [], callOnWrite, quitCallback(this._client)))
|
||||
return this
|
||||
}
|
||||
|
||||
|
@@ -91,7 +91,7 @@ function execTransaction (multi) {
|
||||
// Drain queue, callback will catch 'QUEUED' or error
|
||||
for (var index = 0; index < len; index++) {
|
||||
// The commands may not be shifted off, since they are needed in the result handler
|
||||
promises.push(pipelineTransactionCommand(multi, queue.get(index), index).catch((e) => e))
|
||||
promises.push(pipelineTransactionCommand(multi, queue.peekAt(index), index).catch((e) => e))
|
||||
}
|
||||
|
||||
const main = client.internalSendCommand(new Command('exec', []))
|
||||
@@ -130,7 +130,7 @@ function execBatch (multi) {
|
||||
return Promise.all(promises).then((res) => {
|
||||
if (error) {
|
||||
const err = new Errors.RedisError('bla failed')
|
||||
err.code = 'foo'
|
||||
err.code = 'ERR'
|
||||
err.replies = res
|
||||
return Promise.reject(err)
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@ const SUBSCRIBE_COMMANDS = {
|
||||
function subscribeUnsubscribe (client, reply, type) {
|
||||
// Subscribe commands take an optional callback and also emit an event, but only the Last_ response is included in the callback
|
||||
// The pub sub commands return each argument in a separate return value and have to be handled that way
|
||||
const commandObj = client.commandQueue.get(0)
|
||||
const commandObj = client.commandQueue.peekAt(0)
|
||||
const buffer = client._options.returnBuffers || client._options.detectBuffers && commandObj.bufferArgs
|
||||
const channel = (buffer || reply[1] === null) ? reply[1] : reply[1].toString()
|
||||
const count = +reply[2] // Return the channel counter as number no matter if `stringNumbers` is activated or not
|
||||
@@ -31,16 +31,14 @@ function subscribeUnsubscribe (client, reply, type) {
|
||||
|
||||
if (commandObj.argsLength === 1 || client._subCommandsLeft === 1 || commandObj.argsLength === 0 && (count === 0 || channel === null)) {
|
||||
if (count === 0) { // Unsubscribed from all channels
|
||||
var runningCommand
|
||||
var i = 1
|
||||
client._pubSubMode = 0 // Deactivating pub sub mode
|
||||
// This should be a rare case and therefore handling it this way should be good performance wise for the general case
|
||||
for (runningCommand = client.commandQueue.get(i); runningCommand !== undefined; runningCommand = client.commandQueue.get(i)) {
|
||||
for (var i = 1; i < client.commandQueue.length; i++) {
|
||||
const runningCommand = client.commandQueue.peekAt(i)
|
||||
if (SUBSCRIBE_COMMANDS[runningCommand.command]) {
|
||||
client._pubSubMode = i // Entering pub sub mode again
|
||||
break
|
||||
}
|
||||
i++
|
||||
}
|
||||
}
|
||||
client.commandQueue.shift()
|
||||
|
@@ -507,6 +507,15 @@ describe('connection tests', () => {
|
||||
assert(delayed)
|
||||
end()
|
||||
})
|
||||
// Cover info parts with no value
|
||||
setImmediate(() => {
|
||||
const command = client.commandQueue.peekAt(0)
|
||||
const callback = command.callback
|
||||
command.callback = (err, res) => {
|
||||
res += 'added:\r\n'
|
||||
callback(err, res)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('redis still loading > 1000ms', (done) => {
|
||||
|
Reference in New Issue
Block a user