File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -25,18 +25,26 @@ import Pool from '../../src/v1/internal/pool';
25
25
describe ( 'RoutingDriver' , ( ) => {
26
26
27
27
it ( 'should create least connected when nothing configured' , ( ) => {
28
- const strategy = RoutingDriver . _createLoadBalancingStrategy ( { } , new Pool ( ) ) ;
28
+ const strategy = createStrategy ( { } ) ;
29
29
expect ( strategy instanceof LeastConnectedLoadBalancingStrategy ) . toBeTruthy ( ) ;
30
30
} ) ;
31
31
32
32
it ( 'should create least connected when it is configured' , ( ) => {
33
- const strategy = RoutingDriver . _createLoadBalancingStrategy ( { loadBalancingStrategy : 'least_connected' } , new Pool ( ) ) ;
33
+ const strategy = createStrategy ( { loadBalancingStrategy : 'least_connected' } ) ;
34
34
expect ( strategy instanceof LeastConnectedLoadBalancingStrategy ) . toBeTruthy ( ) ;
35
35
} ) ;
36
36
37
37
it ( 'should create round robin when it is configured' , ( ) => {
38
- const strategy = RoutingDriver . _createLoadBalancingStrategy ( { loadBalancingStrategy : 'round_robin' } , new Pool ( ) ) ;
38
+ const strategy = createStrategy ( { loadBalancingStrategy : 'round_robin' } ) ;
39
39
expect ( strategy instanceof RoundRobinLoadBalancingStrategy ) . toBeTruthy ( ) ;
40
40
} ) ;
41
41
42
+ it ( 'should fail when unknown strategy is configured' , ( ) => {
43
+ expect ( ( ) => createStrategy ( { loadBalancingStrategy : 'wrong' } ) ) . toThrow ( ) ;
44
+ } ) ;
45
+
42
46
} ) ;
47
+
48
+ function createStrategy ( config ) {
49
+ return RoutingDriver . _createLoadBalancingStrategy ( config , new Pool ( ) ) ;
50
+ }
You can’t perform that action at this time.
0 commit comments