1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-04 15:02:09 +03:00

V5 bringing RESP3, Sentinel and TypeMapping to node-redis

RESP3 Support
   - Some commands responses in RESP3 aren't stable yet and therefore return an "untyped" ReplyUnion.
 
Sentinel

TypeMapping

Correctly types Multi commands

Note: some API changes to be further documented in v4-to-v5.md
This commit is contained in:
Shaya Potter
2024-10-15 17:46:52 +03:00
committed by GitHub
parent 2fc79bdfb3
commit b2d35c5286
1174 changed files with 45931 additions and 36274 deletions

View File

@@ -1,55 +1,20 @@
import { strict as assert } from 'assert';
import { strict as assert } from 'node:assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments, transformReply } from './CLUSTER_INFO';
import CLUSTER_INFO from './CLUSTER_INFO';
describe('CLUSTER INFO', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments(),
['CLUSTER', 'INFO']
);
});
it('transformArguments', () => {
assert.deepEqual(
CLUSTER_INFO.transformArguments(),
['CLUSTER', 'INFO']
);
});
it('transformReply', () => {
assert.deepEqual(
transformReply([
'cluster_state:ok',
'cluster_slots_assigned:16384',
'cluster_slots_ok:16384',
'cluster_slots_pfail:0',
'cluster_slots_fail:0',
'cluster_known_nodes:6',
'cluster_size:3',
'cluster_current_epoch:6',
'cluster_my_epoch:2',
'cluster_stats_messages_sent:1483972',
'cluster_stats_messages_received:1483968'
].join('\r\n')),
{
state: 'ok',
slots: {
assigned: 16384,
ok: 16384,
pfail: 0,
fail: 0
},
knownNodes: 6,
size: 3,
currentEpoch: 6,
myEpoch: 2,
stats: {
messagesSent: 1483972,
messagesReceived: 1483968
}
}
);
});
testUtils.testWithCluster('clusterNode.clusterInfo', async cluster => {
const client = await cluster.nodeClient(cluster.masters[0]);
assert.notEqual(
await client.clusterInfo(),
null
);
}, GLOBAL.CLUSTERS.OPEN);
testUtils.testWithCluster('clusterNode.clusterInfo', async cluster => {
const client = await cluster.nodeClient(cluster.masters[0]);
assert.equal(
typeof await client.clusterInfo(),
'string'
);
}, GLOBAL.CLUSTERS.OPEN);
});