test: code cleanup
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 13 Dec 2023 13:44:57 +0000 (14:44 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 13 Dec 2023 13:44:57 +0000 (14:44 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
tests/pools/selection-strategies/worker-choice-strategy-context.test.mjs

index a5447b73f7fdaa7b3f5fa6a6905484b1d34f2b2b..bb8c7fefb3a1567919af0736f698c6e6f4a55359 100644 (file)
@@ -80,6 +80,9 @@ describe('Worker choice strategy context test suite', () => {
     const workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
       fixedPool
     )
+    expect(workerChoiceStrategyContext.workerChoiceStrategy).toBe(
+      WorkerChoiceStrategies.ROUND_ROBIN
+    )
     const workerChoiceStrategyUndefinedStub = createStubInstance(
       RoundRobinWorkerChoiceStrategy,
       {
@@ -87,16 +90,6 @@ describe('Worker choice strategy context test suite', () => {
         choose: stub().returns(undefined)
       }
     )
-    const workerChoiceStrategyNullStub = createStubInstance(
-      RoundRobinWorkerChoiceStrategy,
-      {
-        hasPoolWorkerNodesReady: stub().returns(true),
-        choose: stub().returns(null)
-      }
-    )
-    expect(workerChoiceStrategyContext.workerChoiceStrategy).toBe(
-      WorkerChoiceStrategies.ROUND_ROBIN
-    )
     workerChoiceStrategyContext.workerChoiceStrategies.set(
       workerChoiceStrategyContext.workerChoiceStrategy,
       workerChoiceStrategyUndefinedStub
@@ -104,6 +97,13 @@ describe('Worker choice strategy context test suite', () => {
     expect(() => workerChoiceStrategyContext.execute()).toThrow(
       new Error('Worker node key chosen is null or undefined after 6 retries')
     )
+    const workerChoiceStrategyNullStub = createStubInstance(
+      RoundRobinWorkerChoiceStrategy,
+      {
+        hasPoolWorkerNodesReady: stub().returns(true),
+        choose: stub().returns(null)
+      }
+    )
     workerChoiceStrategyContext.workerChoiceStrategies.set(
       workerChoiceStrategyContext.workerChoiceStrategy,
       workerChoiceStrategyNullStub