fix: properly account worker choice retries for WRR
[poolifier.git] / tests / pools / selection-strategies / worker-choice-strategy-context.test.mjs
index f076f4ddda866dc79735530a8ec4003202dee772..2b8d35d8f485f1ac45ffa6fd203ce33dd6f04073 100644 (file)
@@ -96,7 +96,10 @@ describe('Worker choice strategy context test suite', () => {
     )
     expect(() => workerChoiceStrategyContext.execute()).toThrow(
       new Error(
-        `Worker node key chosen is null or undefined after ${fixedPool.info.maxSize} retries`
+        `Worker node key chosen is null or undefined after ${
+          fixedPool.info.maxSize +
+          Object.keys(workerChoiceStrategyContext.opts.weights).length
+        } retries`
       )
     )
     const workerChoiceStrategyNullStub = createStubInstance(
@@ -112,7 +115,10 @@ describe('Worker choice strategy context test suite', () => {
     )
     expect(() => workerChoiceStrategyContext.execute()).toThrow(
       new Error(
-        `Worker node key chosen is null or undefined after ${fixedPool.info.maxSize} retries`
+        `Worker node key chosen is null or undefined after ${
+          fixedPool.info.maxSize +
+          Object.keys(workerChoiceStrategyContext.opts.weights).length
+        } retries`
       )
     )
   })