You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-17 19:41:06 +03:00
86 lines
2.8 KiB
TypeScript
86 lines
2.8 KiB
TypeScript
import { strict as assert } from 'assert';
|
|
import { RedisClusterNodeLinkStates, transformArguments, transformReply } from './CLUSTER_NODES.js';
|
|
|
|
describe('CLUSTER NODES', () => {
|
|
it('transformArguments', () => {
|
|
assert.deepEqual(
|
|
transformArguments(),
|
|
['CLUSTER', 'NODES']
|
|
);
|
|
});
|
|
|
|
describe('transformReply', () => {
|
|
it('simple', () => {
|
|
assert.deepEqual(
|
|
transformReply([
|
|
'master 127.0.0.1:30001@31001 myself,master - 0 0 1 connected 0-16384',
|
|
'slave 127.0.0.1:30002@31002 slave master 0 0 1 connected',
|
|
''
|
|
].join('\n')),
|
|
[{
|
|
id: 'master',
|
|
url: '127.0.0.1:30001@31001',
|
|
flags: ['myself', 'master'],
|
|
master: null,
|
|
pingSent: 0,
|
|
pongRecv: 0,
|
|
configEpoch: 1,
|
|
linkState: RedisClusterNodeLinkStates.CONNECTED,
|
|
slots: [{
|
|
from: 0,
|
|
to: 16384
|
|
}]
|
|
}, {
|
|
id: 'slave',
|
|
url: '127.0.0.1:30002@31002',
|
|
flags: ['slave'],
|
|
master: 'master',
|
|
pingSent: 0,
|
|
pongRecv: 0,
|
|
configEpoch: 1,
|
|
linkState: RedisClusterNodeLinkStates.CONNECTED,
|
|
slots: []
|
|
}]
|
|
);
|
|
});
|
|
|
|
it.skip('with importing slots', () => {
|
|
assert.deepEqual(
|
|
transformReply(
|
|
'id 127.0.0.1:30001@31001 master - 0 0 0 connected 0-<-16384'
|
|
),
|
|
[{
|
|
id: 'id',
|
|
url: '127.0.0.1:30001@31001',
|
|
flags: ['master'],
|
|
master: null,
|
|
pingSent: 0,
|
|
pongRecv: 0,
|
|
configEpoch: 0,
|
|
linkState: RedisClusterNodeLinkStates.CONNECTED,
|
|
slots: [] // TODO
|
|
}]
|
|
);
|
|
});
|
|
|
|
it.skip('with migrating slots', () => {
|
|
assert.deepEqual(
|
|
transformReply(
|
|
'id 127.0.0.1:30001@31001 master - 0 0 0 connected 0->-16384'
|
|
),
|
|
[{
|
|
id: 'id',
|
|
url: '127.0.0.1:30001@31001',
|
|
flags: ['master'],
|
|
master: null,
|
|
pingSent: 0,
|
|
pongRecv: 0,
|
|
configEpoch: 0,
|
|
linkState: RedisClusterNodeLinkStates.CONNECTED,
|
|
slots: [] // TODO
|
|
}]
|
|
);
|
|
});
|
|
});
|
|
});
|