1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-17 19:41:06 +03:00

fix CLUSTER_NODES, add some tests

This commit is contained in:
leibale
2021-06-28 20:45:42 -04:00
parent 33f8d5e484
commit 22c2748fa8
3 changed files with 44 additions and 3 deletions

View File

@@ -1,4 +1,5 @@
import { strict as assert } from 'assert';
import { itWithCluster, TestRedisClusters } from '../test-utils';
import { RedisClusterNodeLinkStates, transformArguments, transformReply } from './CLUSTER_NODES';
describe('CLUSTER NODES', () => {
@@ -92,4 +93,26 @@ describe('CLUSTER NODES', () => {
);
});
});
itWithCluster(TestRedisClusters.OPEN, 'cluster.clusterNodes', async cluster => {
const nodes = await cluster.clusterNodes();
for (const node of (await cluster.clusterNodes())) {
assert.equal(typeof node.id, 'string');
assert.equal(typeof node.url, 'string');
assert.equal(typeof node.host, 'string');
assert.equal(typeof node.port, 'number');
assert.equal(typeof node.cport, 'number');
assert.ok(Array.isArray(node.flags));
assert.equal(typeof node.pingSent, 'number');
assert.equal(typeof node.pongRecv, 'number');
assert.equal(typeof node.configEpoch, 'number');
assert.equal(typeof node.linkState, 'string');
for (const slot of node.slots) {
assert.equal(typeof slot.from, 'number');
assert.equal(typeof slot.to, 'number');
}
}
});
});