From: Jérôme Benoit Date: Mon, 1 Jan 2024 10:17:18 +0000 (+0100) Subject: test: improve worker choice strategies options tests X-Git-Tag: v3.1.14~2 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=125c84e40d6ee90f9b5e91f732a92e7b2503ebd8;p=poolifier.git test: improve worker choice strategies options tests Signed-off-by: Jérôme Benoit --- diff --git a/tests/utils.test.mjs b/tests/utils.test.mjs index 5e089e29..5f54f6fc 100644 --- a/tests/utils.test.mjs +++ b/tests/utils.test.mjs @@ -244,6 +244,21 @@ describe('Utils test suite', () => { './tests/worker-files/thread/testWorker.mjs' ) expect(getWorkerChoiceStrategyRetries(pool)).toBe(pool.info.maxSize * 2) + const workerChoiceStrategyOptions = { + runTime: { median: true }, + waitTime: { median: true }, + elu: { median: true }, + weights: { + 0: 100, + 1: 100 + } + } + expect( + getWorkerChoiceStrategyRetries(pool, workerChoiceStrategyOptions) + ).toBe( + pool.info.maxSize + + Object.keys(workerChoiceStrategyOptions.weights).length + ) await pool.destroy() }) @@ -262,6 +277,18 @@ describe('Utils test suite', () => { [pool.info.maxSize - 1]: expect.any(Number) }) }) + const workerChoiceStrategyOptions = { + runTime: { median: true }, + waitTime: { median: true }, + elu: { median: true }, + weights: { + 0: 100, + 1: 100 + } + } + expect( + buildWorkerChoiceStrategyOptions(pool, workerChoiceStrategyOptions) + ).toStrictEqual(workerChoiceStrategyOptions) await pool.destroy() })