Skip to content

Commit 9cbe000

Browse files
committed
cluster with commandOptions unit test
1 parent 2c4ee4e commit 9cbe000

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

packages/client/lib/cluster/index.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { strict as assert } from 'assert';
22
import testUtils, { GLOBAL, waitTillBeenCalled } from '../test-utils';
33
import RedisCluster from '.';
44
import { ClusterSlotStates } from '../commands/CLUSTER_SETSLOT';
5+
import { commandOptions } from '../command-options';
56
import { SQUARE_SCRIPT } from '../client/index.spec';
67
import { RootNodesUnavailableError } from '../errors';
78
import { spy } from 'sinon';
@@ -178,6 +179,21 @@ describe('Cluster', () => {
178179
await assert.rejects(cluster.mGet(['a', 'b']));
179180
}, GLOBAL.CLUSTERS.OPEN);
180181

182+
testUtils.testWithCluster('should send commands with commandOptions to correct cluster slot (without redirections)', async cluster => {
183+
// 'a' and 'b' hash to different cluster slots (see previous unit test)
184+
// -> maxCommandRedirections 0: rejects on MOVED/ASK reply
185+
await cluster.set(commandOptions({ isolated: true }), 'a', '1'),
186+
await cluster.set(commandOptions({ isolated: true }), 'b', '2'),
187+
188+
assert.equal(await cluster.get('a'), '1');
189+
assert.equal(await cluster.get('b'), '2');
190+
}, {
191+
...GLOBAL.CLUSTERS.OPEN,
192+
clusterConfiguration: {
193+
maxCommandRedirections: 0,
194+
}
195+
});
196+
181197
describe('minimizeConnections', () => {
182198
testUtils.testWithCluster('false', async cluster => {
183199
for (const master of cluster.masters) {

0 commit comments

Comments
 (0)