From: Jérôme Benoit Date: Sat, 15 Oct 2022 14:17:24 +0000 (+0200) Subject: Tests: use getter for worker choice strategy instance X-Git-Tag: v2.3.4~17 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=b0afa8e5b4aa17b920ac920a5e517993afccc2a3;p=poolifier.git Tests: use getter for worker choice strategy instance Signed-off-by: Jérôme Benoit --- diff --git a/tests/pools/selection-strategies/worker-choice-strategy-context.test.js b/tests/pools/selection-strategies/worker-choice-strategy-context.test.js index 46ac017c..3ce8b9fe 100644 --- a/tests/pools/selection-strategies/worker-choice-strategy-context.test.js +++ b/tests/pools/selection-strategies/worker-choice-strategy-context.test.js @@ -93,9 +93,9 @@ describe('Worker choice strategy context test suite', () => { workerChoiceStrategyContext.setWorkerChoiceStrategy( WorkerChoiceStrategies.ROUND_ROBIN ) - expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf( - RoundRobinWorkerChoiceStrategy - ) + expect( + workerChoiceStrategyContext.getWorkerChoiceStrategy() + ).toBeInstanceOf(RoundRobinWorkerChoiceStrategy) }) it('Verify that setWorkerChoiceStrategy() works with ROUND_ROBIN and dynamic pool', () => { @@ -105,11 +105,11 @@ describe('Worker choice strategy context test suite', () => { workerChoiceStrategyContext.setWorkerChoiceStrategy( WorkerChoiceStrategies.ROUND_ROBIN ) - expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf( - DynamicPoolWorkerChoiceStrategy - ) expect( - workerChoiceStrategyContext.workerChoiceStrategy.workerChoiceStrategy + workerChoiceStrategyContext.getWorkerChoiceStrategy() + ).toBeInstanceOf(DynamicPoolWorkerChoiceStrategy) + expect( + workerChoiceStrategyContext.getWorkerChoiceStrategy().workerChoiceStrategy ).toBeInstanceOf(RoundRobinWorkerChoiceStrategy) }) @@ -120,9 +120,9 @@ describe('Worker choice strategy context test suite', () => { workerChoiceStrategyContext.setWorkerChoiceStrategy( WorkerChoiceStrategies.LESS_RECENTLY_USED ) - expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf( - LessRecentlyUsedWorkerChoiceStrategy - ) + expect( + workerChoiceStrategyContext.getWorkerChoiceStrategy() + ).toBeInstanceOf(LessRecentlyUsedWorkerChoiceStrategy) }) it('Verify that setWorkerChoiceStrategy() works with LESS_RECENTLY_USED and dynamic pool', () => { @@ -132,11 +132,11 @@ describe('Worker choice strategy context test suite', () => { workerChoiceStrategyContext.setWorkerChoiceStrategy( WorkerChoiceStrategies.LESS_RECENTLY_USED ) - expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf( - DynamicPoolWorkerChoiceStrategy - ) expect( - workerChoiceStrategyContext.workerChoiceStrategy.workerChoiceStrategy + workerChoiceStrategyContext.getWorkerChoiceStrategy() + ).toBeInstanceOf(DynamicPoolWorkerChoiceStrategy) + expect( + workerChoiceStrategyContext.getWorkerChoiceStrategy().workerChoiceStrategy ).toBeInstanceOf(LessRecentlyUsedWorkerChoiceStrategy) }) @@ -147,9 +147,9 @@ describe('Worker choice strategy context test suite', () => { workerChoiceStrategyContext.setWorkerChoiceStrategy( WorkerChoiceStrategies.FAIR_SHARE ) - expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf( - FairShareWorkerChoiceStrategy - ) + expect( + workerChoiceStrategyContext.getWorkerChoiceStrategy() + ).toBeInstanceOf(FairShareWorkerChoiceStrategy) }) it('Verify that setWorkerChoiceStrategy() works with FAIR_SHARE and dynamic pool', () => { @@ -159,11 +159,11 @@ describe('Worker choice strategy context test suite', () => { workerChoiceStrategyContext.setWorkerChoiceStrategy( WorkerChoiceStrategies.FAIR_SHARE ) - expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf( - DynamicPoolWorkerChoiceStrategy - ) expect( - workerChoiceStrategyContext.workerChoiceStrategy.workerChoiceStrategy + workerChoiceStrategyContext.getWorkerChoiceStrategy() + ).toBeInstanceOf(DynamicPoolWorkerChoiceStrategy) + expect( + workerChoiceStrategyContext.getWorkerChoiceStrategy().workerChoiceStrategy ).toBeInstanceOf(FairShareWorkerChoiceStrategy) }) @@ -174,9 +174,9 @@ describe('Worker choice strategy context test suite', () => { workerChoiceStrategyContext.setWorkerChoiceStrategy( WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN ) - expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf( - WeightedRoundRobinWorkerChoiceStrategy - ) + expect( + workerChoiceStrategyContext.getWorkerChoiceStrategy() + ).toBeInstanceOf(WeightedRoundRobinWorkerChoiceStrategy) }) it('Verify that setWorkerChoiceStrategy() works with WEIGHTED_ROUND_ROBIN and dynamic pool', () => { @@ -186,11 +186,11 @@ describe('Worker choice strategy context test suite', () => { workerChoiceStrategyContext.setWorkerChoiceStrategy( WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN ) - expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf( - DynamicPoolWorkerChoiceStrategy - ) expect( - workerChoiceStrategyContext.workerChoiceStrategy.workerChoiceStrategy + workerChoiceStrategyContext.getWorkerChoiceStrategy() + ).toBeInstanceOf(DynamicPoolWorkerChoiceStrategy) + expect( + workerChoiceStrategyContext.getWorkerChoiceStrategy().workerChoiceStrategy ).toBeInstanceOf(WeightedRoundRobinWorkerChoiceStrategy) }) })