1
0
mirror of https://github.com/redis/node-redis.git synced 2025-12-11 09:22:35 +03:00

fix(cmd): PUBSUB_NUMSUB return count as number (#3103)

fixes: #3102
This commit is contained in:
Nikolay Karadzhov
2025-10-21 11:37:22 +03:00
committed by GitHub
parent d7c6544d3a
commit 1cda848393
2 changed files with 33 additions and 5 deletions

View File

@@ -27,10 +27,38 @@ describe('PUBSUB NUMSUB', () => {
}); });
}); });
testUtils.testWithClient('client.pubSubNumSub', async client => { testUtils.testWithClient('client.pubSubNumSub resp2', async client => {
assert.deepEqual( assert.deepEqual(
await client.pubSubNumSub(), await client.pubSubNumSub(),
Object.create(null) Object.create(null)
); );
}, GLOBAL.SERVERS.OPEN);
const res = await client.PUBSUB_NUMSUB(["test", "test2"]);
assert.equal(res.test, 0);
assert.equal(res.test2, 0);
}, {
...GLOBAL.SERVERS.OPEN,
clientOptions: {
RESP: 2
}
});
testUtils.testWithClient('client.pubSubNumSub resp3', async client => {
assert.deepEqual(
await client.pubSubNumSub(),
Object.create(null)
);
const res = await client.PUBSUB_NUMSUB(["test", "test2"]);
assert.equal(res.test, 0);
assert.equal(res.test2, 0);
}, {
...GLOBAL.SERVERS.OPEN,
clientOptions: {
RESP: 3
}
});
}); });

View File

@@ -29,7 +29,7 @@ export default {
const reply = Object.create(null); const reply = Object.create(null);
let i = 0; let i = 0;
while (i < rawReply.length) { while (i < rawReply.length) {
reply[rawReply[i++].toString()] = rawReply[i++].toString(); reply[rawReply[i++].toString()] = Number(rawReply[i++]);
} }
return reply as Record<string, NumberReply>; return reply as Record<string, NumberReply>;