X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=tests%2Fpools%2Fthread%2Ffixed.test.js;h=ec756aa53b99097e23568d0c02e0a586031c0e6c;hb=7d27ec0dd77a2b67c9e7ab20831bc70a6051a853;hp=065774ec695ef29a3c94dec2a96830d5f82cd68d;hpb=9274aa140e25aed36590c375f621f36edca4ca17;p=poolifier.git diff --git a/tests/pools/thread/fixed.test.js b/tests/pools/thread/fixed.test.js index 065774ec..ec756aa5 100644 --- a/tests/pools/thread/fixed.test.js +++ b/tests/pools/thread/fixed.test.js @@ -301,16 +301,33 @@ describe('Fixed thread pool test suite', () => { }) it('Should work even without opts in input', async () => { - const pool = new FixedThreadPool( - numberOfThreads, - './tests/worker-files/thread/testWorker.js' - ) + const workerFilePath = './tests/worker-files/thread/testWorker.js' + const pool = new FixedThreadPool(numberOfThreads, workerFilePath) const res = await pool.execute() expect(res).toStrictEqual({ ok: 1 }) // We need to clean up the resources after our test await pool.destroy() }) + it('Verify destroyWorkerNode()', async () => { + const workerFilePath = './tests/worker-files/thread/testWorker.js' + const pool = new FixedThreadPool(numberOfThreads, workerFilePath) + let exitEvent = 0 + pool.workerNodes[0].worker.on('exit', () => { + ++exitEvent + }) + let error + try { + await pool.destroyWorkerNode(0) + } catch (e) { + error = e + } + expect(error).toBeUndefined() + expect(exitEvent).toBe(1) + expect(pool.workerNodes.length).toBe(numberOfThreads - 1) + await pool.destroy() + }) + it('Verify that a pool with zero worker fails', async () => { expect( () => new FixedThreadPool(0, './tests/worker-files/thread/testWorker.js')