Allow worker choice strategy to specify their statistics requirements
[poolifier.git] / tests / pools / abstract / abstract-pool.test.js
index 1e337ff9f4a3a3cd18800434d65965679c7d6535..6a4da63d8a479b28410464bf9073118b28444fe4 100644 (file)
@@ -158,7 +158,7 @@ describe('Abstract pool test suite', () => {
     pool.destroy()
   })
 
-  it('Simulate worker not found during updateWorkerTasksRunTime', () => {
+  it('Simulate worker not found during updateWorkerTasksRunTime with strategy not requiring it', () => {
     const pool = new StubPoolWithWorkerTasksUsageMapClear(
       numberOfWorkers,
       './tests/worker-files/cluster/testWorker.js',
@@ -168,6 +168,21 @@ describe('Abstract pool test suite', () => {
     )
     // Simulate worker not found.
     pool.removeAllWorker()
+    expect(() => pool.updateWorkerTasksRunTime()).not.toThrowError()
+    pool.destroy()
+  })
+
+  it('Simulate worker not found during updateWorkerTasksRunTime with strategy requiring it', () => {
+    const pool = new StubPoolWithWorkerTasksUsageMapClear(
+      numberOfWorkers,
+      './tests/worker-files/cluster/testWorker.js',
+      {
+        workerChoiceStrategy: WorkerChoiceStrategies.FAIR_SHARE,
+        errorHandler: e => console.error(e)
+      }
+    )
+    // Simulate worker not found.
+    pool.removeAllWorker()
     expect(() => pool.updateWorkerTasksRunTime()).toThrowError(
       workerNotFoundInTasksUsageMapError
     )