@@ -2,6 +2,7 @@ import { strict as assert } from 'assert';
2
2
import testUtils , { GLOBAL , waitTillBeenCalled } from '../test-utils' ;
3
3
import RedisCluster from '.' ;
4
4
import { ClusterSlotStates } from '../commands/CLUSTER_SETSLOT' ;
5
+ import { commandOptions } from '../command-options' ;
5
6
import { SQUARE_SCRIPT } from '../client/index.spec' ;
6
7
import { RootNodesUnavailableError } from '../errors' ;
7
8
import { spy } from 'sinon' ;
@@ -178,6 +179,21 @@ describe('Cluster', () => {
178
179
await assert . rejects ( cluster . mGet ( [ 'a' , 'b' ] ) ) ;
179
180
} , GLOBAL . CLUSTERS . OPEN ) ;
180
181
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
+
181
197
describe ( 'minimizeConnections' , ( ) => {
182
198
testUtils . testWithCluster ( 'false' , async cluster => {
183
199
for ( const master of cluster . masters ) {
0 commit comments