11import { strict as assert } from 'assert' ;
22import testUtils , { GLOBAL } from '../test-utils' ;
3+ import RedisCluster from '.' ;
34import { ClusterSlotStates } from '../commands/CLUSTER_SETSLOT' ;
45import { SQUARE_SCRIPT } from '../client/index.spec' ;
6+ import { RootNodesUnavailableError } from '../errors' ;
57
68// We need to use 'require', because it's not possible with Typescript to import
79// function that are exported as 'module.exports = function`, without esModuleInterop
@@ -10,20 +12,14 @@ const calculateSlot = require('cluster-key-slot');
1012
1113describe ( 'Cluster' , ( ) => {
1214 testUtils . testWithCluster ( 'sendCommand' , async cluster => {
13- await cluster . connect ( ) ;
14-
15- try {
16- await cluster . publish ( 'channel' , 'message' ) ;
17- await cluster . set ( 'a' , 'b' ) ;
18- await cluster . set ( 'a{a}' , 'bb' ) ;
19- await cluster . set ( 'aa' , 'bb' ) ;
20- await cluster . get ( 'aa' ) ;
21- await cluster . get ( 'aa' ) ;
22- await cluster . get ( 'aa' ) ;
23- await cluster . get ( 'aa' ) ;
24- } finally {
25- await cluster . disconnect ( ) ;
26- }
15+ await cluster . publish ( 'channel' , 'message' ) ;
16+ await cluster . set ( 'a' , 'b' ) ;
17+ await cluster . set ( 'a{a}' , 'bb' ) ;
18+ await cluster . set ( 'aa' , 'bb' ) ;
19+ await cluster . get ( 'aa' ) ;
20+ await cluster . get ( 'aa' ) ;
21+ await cluster . get ( 'aa' ) ;
22+ await cluster . get ( 'aa' ) ;
2723 } , GLOBAL . CLUSTERS . OPEN ) ;
2824
2925 testUtils . testWithCluster ( 'multi' , async cluster => {
@@ -51,6 +47,22 @@ describe('Cluster', () => {
5147 }
5248 } ) ;
5349
50+ it ( 'should throw RootNodesUnavailableError' , async ( ) => {
51+ const cluster = RedisCluster . create ( {
52+ rootNodes : [ ]
53+ } ) ;
54+
55+ try {
56+ await assert . rejects (
57+ cluster . connect ( ) ,
58+ RootNodesUnavailableError
59+ ) ;
60+ } catch ( err ) {
61+ await cluster . disconnect ( ) ;
62+ throw err ;
63+ }
64+ } ) ;
65+
5466 testUtils . testWithCluster ( 'should handle live resharding' , async cluster => {
5567 const key = 'key' ,
5668 value = 'value' ;
0 commit comments