From: Jérôme Benoit Date: Mon, 8 May 2023 09:16:06 +0000 (+0200) Subject: test: enchance worker node key choice tests X-Git-Tag: v2.4.13~8 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=fa418e129ade4cd910e34e9d41c3dfa5cac9b2de;p=poolifier.git test: enchance worker node key choice tests 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 0d4d8116d..f04013d99 100644 --- a/tests/pools/selection-strategies/worker-choice-strategy-context.test.js +++ b/tests/pools/selection-strategies/worker-choice-strategy-context.test.js @@ -89,18 +89,31 @@ describe('Worker choice strategy context test suite', () => { const workerChoiceStrategyContext = new WorkerChoiceStrategyContext( fixedPool ) - const WorkerChoiceStrategyStub = sinon.createStubInstance( + const WorkerChoiceStrategyUndefinedStub = sinon.createStubInstance( RoundRobinWorkerChoiceStrategy, { choose: sinon.stub().returns(undefined) } ) + const WorkerChoiceStrategyNullStub = sinon.createStubInstance( + RoundRobinWorkerChoiceStrategy, + { + choose: sinon.stub().returns(null) + } + ) expect(workerChoiceStrategyContext.workerChoiceStrategy).toBe( WorkerChoiceStrategies.ROUND_ROBIN ) workerChoiceStrategyContext.workerChoiceStrategies.set( workerChoiceStrategyContext.workerChoiceStrategy, - WorkerChoiceStrategyStub + WorkerChoiceStrategyUndefinedStub + ) + expect(() => workerChoiceStrategyContext.execute()).toThrowError( + new Error('Worker node key chosen is null or undefined') + ) + workerChoiceStrategyContext.workerChoiceStrategies.set( + workerChoiceStrategyContext.workerChoiceStrategy, + WorkerChoiceStrategyNullStub ) expect(() => workerChoiceStrategyContext.execute()).toThrowError( new Error('Worker node key chosen is null or undefined')