Bump rollup from 2.39.0 to 2.39.1 (#224)
[poolifier.git] / tests / pools / cluster / fixed.test.js
index 63399c6e4629ba4326080153cf5448ae3f2d7f40..a5eaa29ab5a4b1430066721decf5c451f8ae9180 100644 (file)
@@ -2,7 +2,6 @@ const expect = require('expect')
 const { FixedClusterPool } = require('../../../lib/index')
 const TestUtils = require('../../test-utils')
 const numberOfWorkers = 10
-const maxTasks = 500
 const pool = new FixedClusterPool(
   numberOfWorkers,
   './tests/worker-files/cluster/testWorker.js',
@@ -25,7 +24,6 @@ const errorPool = new FixedClusterPool(
     errorHandler: e => console.error(e)
   }
 )
-
 const asyncErrorPool = new FixedClusterPool(
   1,
   './tests/worker-files/cluster/asyncErrorWorker.js',
@@ -35,13 +33,10 @@ const asyncErrorPool = new FixedClusterPool(
 )
 const asyncPool = new FixedClusterPool(
   1,
-  './tests/worker-files/cluster/asyncWorker.js',
-  {
-    maxTasks: maxTasks
-  }
+  './tests/worker-files/cluster/asyncWorker.js'
 )
 
-describe('Fixed cluster pool test suite ', () => {
+describe('Fixed cluster pool test suite', () => {
   after('Destroy all pools', async () => {
     // We need to clean up the resources after our test
     await echoPool.destroy()
@@ -119,11 +114,6 @@ describe('Fixed cluster pool test suite ', () => {
     expect(usedTime).toBeGreaterThanOrEqual(2000)
   })
 
-  it('Verify that maxTasks is set properly', async () => {
-    const worker = asyncPool.chooseWorker()
-    expect(worker.getMaxListeners()).toBe(maxTasks)
-  })
-
   it('Shutdown test', async () => {
     const exitPromise = TestUtils.waitExits(pool, numberOfWorkers)
     await pool.destroy()
@@ -141,4 +131,11 @@ describe('Fixed cluster pool test suite ', () => {
     // We need to clean up the resources after our test
     await pool1.destroy()
   })
+
+  it('Verify that a pool with zero worker fails', async () => {
+    expect(
+      () =>
+        new FixedClusterPool(0, './tests/worker-files/cluster/testWorker.js')
+    ).toThrowError(new Error('Cannot instantiate a fixed pool with no worker'))
+  })
 })