X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=tests%2Fpools%2Fselection-strategies%2Fweighted-round-robin-worker-choice-strategy.test.js;h=e9de670a8a67edcad5dd72118ab4c80de9af686d;hb=3d6dd312a7825521cce506ebb7443bae36a111e6;hp=d8ae8299cfd12874303c4c24e5875afb631585be;hpb=11df35903da6f581c45e8b42e1d4fbd342bddc3c;p=poolifier.git diff --git a/tests/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.test.js b/tests/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.test.js index d8ae8299..e9de670a 100644 --- a/tests/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.test.js +++ b/tests/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.test.js @@ -1,10 +1,10 @@ const { expect } = require('expect') const sinon = require('sinon') -const { FixedThreadPool } = require('../../../lib/index') +const { FixedThreadPool } = require('../../../lib') const { WeightedRoundRobinWorkerChoiceStrategy } = require('../../../lib/pools/selection-strategies/weighted-round-robin-worker-choice-strategy') -const TestUtils = require('../../test-utils') +const { generateRandomInteger } = require('../../test-utils') describe('Weighted round robin strategy worker choice strategy test suite', () => { // const min = 1 @@ -25,17 +25,14 @@ describe('Weighted round robin strategy worker choice strategy test suite', () = it('Verify that reset() resets internals', () => { const strategy = new WeightedRoundRobinWorkerChoiceStrategy(pool) - strategy.currentWorkerIndex = TestUtils.generateRandomInteger() - const workersTaskRunTimeClearStub = sinon - .stub(strategy.workersTaskRunTime, 'clear') - .returns() - const initWorkersTaskRunTimeStub = sinon - .stub(strategy, 'initWorkersTaskRunTime') - .returns() + strategy.currentWorkerId = generateRandomInteger(Number.MAX_SAFE_INTEGER, 1) + strategy.workerVirtualTaskRunTime = generateRandomInteger( + Number.MAX_SAFE_INTEGER, + 1 + ) const resetResult = strategy.reset() expect(resetResult).toBe(true) - expect(strategy.currentWorkerIndex).toBe(0) - expect(workersTaskRunTimeClearStub.calledOnce).toBe(true) - expect(initWorkersTaskRunTimeStub.calledOnce).toBe(true) + expect(strategy.nextWorkerNodeKey).toBe(0) + expect(strategy.workerVirtualTaskRunTime).toBe(0) }) })