perf: use worker key as much as possible instead of a reference to the
[poolifier.git] / tests / pools / selection-strategies / worker-choice-strategy-context.test.js
index 9380a038800abcb246c532240717940fe735e79f..9ab2babfd31ce26fa6286338ced68d2e4f2ae7ea 100644 (file)
@@ -60,15 +60,15 @@ describe('Worker choice strategy context test suite', () => {
     const WorkerChoiceStrategyStub = sinon.createStubInstance(
       RoundRobinWorkerChoiceStrategy,
       {
-        choose: sinon.stub().returns('worker')
+        choose: sinon.stub().returns(0)
       }
     )
     workerChoiceStrategyContext.workerChoiceStrategy = WorkerChoiceStrategyStub
-    const chosenWorker = workerChoiceStrategyContext.execute()
+    const chosenWorkerKey = workerChoiceStrategyContext.execute()
     expect(
       workerChoiceStrategyContext.getWorkerChoiceStrategy().choose.calledOnce
     ).toBe(true)
-    expect(chosenWorker).toBe('worker')
+    expect(chosenWorkerKey).toBe(0)
   })
 
   it('Verify that execute() return the worker chosen by the strategy with dynamic pool', () => {
@@ -78,15 +78,15 @@ describe('Worker choice strategy context test suite', () => {
     const WorkerChoiceStrategyStub = sinon.createStubInstance(
       RoundRobinWorkerChoiceStrategy,
       {
-        choose: sinon.stub().returns('worker')
+        choose: sinon.stub().returns(0)
       }
     )
     workerChoiceStrategyContext.workerChoiceStrategy = WorkerChoiceStrategyStub
-    const chosenWorker = workerChoiceStrategyContext.execute()
+    const chosenWorkerKey = workerChoiceStrategyContext.execute()
     expect(
       workerChoiceStrategyContext.getWorkerChoiceStrategy().choose.calledOnce
     ).toBe(true)
-    expect(chosenWorker).toBe('worker')
+    expect(chosenWorkerKey).toBe(0)
   })
 
   it('Verify that setWorkerChoiceStrategy() works with ROUND_ROBIN and fixed pool', () => {