test: improve worker choice strategies options tests
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 1 Jan 2024 10:17:18 +0000 (11:17 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 1 Jan 2024 10:17:18 +0000 (11:17 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
tests/utils.test.mjs

index 5e089e291f07877506ff12a3373ca407ee2b5c51..5f54f6fc8ea4e0ebe7d7f6ebc27f0efb8a5ea218 100644 (file)
@@ -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()
   })