Coverage ci (#132)
[poolifier.git] / tests / pools / cluster / fixed.test.js
index 7e319ac686ea3fc63e36e40682e1c4ade38ab7db..1a150dac2705bde9dc94ac351086b6ba81de83da 100644 (file)
@@ -1,6 +1,7 @@
 const expect = require('expect')
 const { FixedClusterPool } = require('../../../lib/index')
 const numWorkers = 10
+const maxTasks = 500
 const pool = new FixedClusterPool(
   numWorkers,
   './tests/worker/cluster/testWorker.js',
@@ -27,13 +28,15 @@ const asyncErrorPool = new FixedClusterPool(
   1,
   './tests/worker/cluster/asyncErrorWorker.js',
   {
-    errorHandler: e => console.error(e),
     onlineHandler: () => console.log('worker is online')
   }
 )
 const asyncPool = new FixedClusterPool(
   1,
-  './tests/worker/cluster/asyncWorker.js'
+  './tests/worker/cluster/asyncWorker.js',
+  {
+    maxTasks: maxTasks
+  }
 )
 
 describe('Fixed cluster pool test suite ', () => {
@@ -105,6 +108,11 @@ 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 () => {
     let closedWorkers = 0
     pool.workers.forEach(w => {