Skip to content

Commit

Permalink
Add test for wrong LB strategy configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
lutovich committed Jul 13, 2017
1 parent c7281ce commit bcf95d1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions test/v1/routing-driver.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,26 @@ import Pool from '../../src/v1/internal/pool';
describe('RoutingDriver', () => {

it('should create least connected when nothing configured', () => {
const strategy = RoutingDriver._createLoadBalancingStrategy({}, new Pool());
const strategy = createStrategy({});
expect(strategy instanceof LeastConnectedLoadBalancingStrategy).toBeTruthy();
});

it('should create least connected when it is configured', () => {
const strategy = RoutingDriver._createLoadBalancingStrategy({loadBalancingStrategy: 'least_connected'}, new Pool());
const strategy = createStrategy({loadBalancingStrategy: 'least_connected'});
expect(strategy instanceof LeastConnectedLoadBalancingStrategy).toBeTruthy();
});

it('should create round robin when it is configured', () => {
const strategy = RoutingDriver._createLoadBalancingStrategy({loadBalancingStrategy: 'round_robin'}, new Pool());
const strategy = createStrategy({loadBalancingStrategy: 'round_robin'});
expect(strategy instanceof RoundRobinLoadBalancingStrategy).toBeTruthy();
});

it('should fail when unknown strategy is configured', () => {
expect(() => createStrategy({loadBalancingStrategy: 'wrong'})).toThrow();
});

});

function createStrategy(config) {
return RoutingDriver._createLoadBalancingStrategy(config, new Pool());
}

0 comments on commit bcf95d1

Please sign in to comment.