feat: internal messaging strict worker id checking
[poolifier.git] / tests / pools / abstract / abstract-pool.test.js
index caec34fd47a0ae267f9c6b5dcfe7648a352e1a2a..6c340ed9f089ea6f9fd5deeb126480dc0e0ab3df 100644 (file)
@@ -16,13 +16,6 @@ const { waitPoolEvents } = require('../../test-utils')
 
 describe('Abstract pool test suite', () => {
   const numberOfWorkers = 2
-  class StubPoolWithRemoveAllWorker extends FixedThreadPool {
-    removeAllWorker () {
-      this.workerNodes = []
-      this.promiseResponseMap.clear()
-      this.handleWorkerReadyMessage = () => {}
-    }
-  }
   class StubPoolWithIsMain extends FixedThreadPool {
     isMain () {
       return false
@@ -99,6 +92,14 @@ describe('Abstract pool test suite', () => {
         'Cannot instantiate a dynamic pool with a minimum pool size equal to the maximum pool size. Use a fixed pool instead'
       )
     )
+    expect(
+      () =>
+        new DynamicThreadPool(0, 0, './tests/worker-files/thread/testWorker.js')
+    ).toThrowError(
+      new RangeError(
+        'Cannot instantiate a dynamic pool with a minimum pool size and a maximum pool size equal to zero'
+      )
+    )
   })
 
   it('Verify that pool options are checked', async () => {
@@ -457,21 +458,6 @@ describe('Abstract pool test suite', () => {
     await pool.destroy()
   })
 
-  it('Simulate worker not found', async () => {
-    const pool = new StubPoolWithRemoveAllWorker(
-      numberOfWorkers,
-      './tests/worker-files/thread/testWorker.js',
-      {
-        errorHandler: e => console.error(e)
-      }
-    )
-    expect(pool.workerNodes.length).toBe(numberOfWorkers)
-    // Simulate worker not found.
-    pool.removeAllWorker()
-    expect(pool.workerNodes.length).toBe(0)
-    await pool.destroy()
-  })
-
   it('Verify that pool worker tasks usage are initialized', async () => {
     const pool = new FixedClusterPool(
       numberOfWorkers,