X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=tests%2Fpools%2Fabstract%2Fabstract-pool.test.js;h=5c367aa2c0ebf52be17b51dc8f961d70cfabc564;hb=7884d1837ee55026fe5204a56f4ebeca17e7e7dd;hp=8652287769af1d63267dde6cc4873e1284fa15e2;hpb=04f4516344e1c6968de6312bcafc8f7e2b3b0eeb;p=poolifier.git diff --git a/tests/pools/abstract/abstract-pool.test.js b/tests/pools/abstract/abstract-pool.test.js index 86522877..5c367aa2 100644 --- a/tests/pools/abstract/abstract-pool.test.js +++ b/tests/pools/abstract/abstract-pool.test.js @@ -1,4 +1,3 @@ -const { MessageChannel } = require('worker_threads') const { expect } = require('expect') const { DynamicClusterPool, @@ -34,7 +33,7 @@ describe('Abstract pool test suite', () => { } ) ).toThrowError( - 'Cannot start a pool from the same worker type as the current pool one' + 'Cannot start a pool from a worker with the same type as the pool' ) }) @@ -588,8 +587,7 @@ describe('Abstract pool test suite', () => { id: expect.any(Number), type: WorkerTypes.thread, dynamic: false, - ready: true, - messageChannel: expect.any(MessageChannel) + ready: true }) } }) @@ -841,11 +839,37 @@ describe('Abstract pool test suite', () => { await pool.destroy() }) - it('Verify that multiple tasks worker is working', async () => { + it('Verify that listTaskFunctions() is working', async () => { + const dynamicThreadPool = new DynamicThreadPool( + Math.floor(numberOfWorkers / 2), + numberOfWorkers, + './tests/worker-files/thread/testMultipleTaskFunctionsWorker.js' + ) + await waitPoolEvents(dynamicThreadPool, PoolEvents.ready, 1) + expect(dynamicThreadPool.listTaskFunctions()).toStrictEqual([ + 'default', + 'jsonIntegerSerialization', + 'factorial', + 'fibonacci' + ]) + const fixedClusterPool = new FixedClusterPool( + numberOfWorkers, + './tests/worker-files/cluster/testMultipleTaskFunctionsWorker.js' + ) + await waitPoolEvents(fixedClusterPool, PoolEvents.ready, 1) + expect(fixedClusterPool.listTaskFunctions()).toStrictEqual([ + 'default', + 'jsonIntegerSerialization', + 'factorial', + 'fibonacci' + ]) + }) + + it('Verify that multiple task functions worker is working', async () => { const pool = new DynamicClusterPool( Math.floor(numberOfWorkers / 2), numberOfWorkers, - './tests/worker-files/cluster/testMultiTasksWorker.js' + './tests/worker-files/cluster/testMultipleTaskFunctionsWorker.js' ) const data = { n: 10 } const result0 = await pool.execute(data)