X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=tests%2Fpools%2Fabstract%2Fabstract-pool.test.js;h=9dca322ecf036abf8ee77be3dcc7a9bcf7354e1b;hb=30500265f2a78b3d472c9c1d0ca5e006306113aa;hp=93e7c256dabaad671a78e53bc1923418bfa6ceef;hpb=059cf20e59d680db96e1d812dd6320ba9af55c1c;p=poolifier.git diff --git a/tests/pools/abstract/abstract-pool.test.js b/tests/pools/abstract/abstract-pool.test.js index 93e7c256..9dca322e 100644 --- a/tests/pools/abstract/abstract-pool.test.js +++ b/tests/pools/abstract/abstract-pool.test.js @@ -1243,7 +1243,7 @@ describe('Abstract pool test suite', () => { await pool.destroy() }) - it('Verify that listTaskFunctions() is working', async () => { + it('Verify that listTaskFunctionNames() is working', async () => { const dynamicThreadPool = new DynamicThreadPool( Math.floor(numberOfWorkers / 2), numberOfWorkers, @@ -1271,6 +1271,36 @@ describe('Abstract pool test suite', () => { await fixedClusterPool.destroy() }) + it('Verify that hasTaskFunction() 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.hasTaskFunction(DEFAULT_TASK_NAME)).toBe(true) + expect(dynamicThreadPool.hasTaskFunction('jsonIntegerSerialization')).toBe( + true + ) + expect(dynamicThreadPool.hasTaskFunction('factorial')).toBe(true) + expect(dynamicThreadPool.hasTaskFunction('fibonacci')).toBe(true) + expect(dynamicThreadPool.hasTaskFunction('unknown')).toBe(false) + const fixedClusterPool = new FixedClusterPool( + numberOfWorkers, + './tests/worker-files/cluster/testMultipleTaskFunctionsWorker.js' + ) + await waitPoolEvents(fixedClusterPool, PoolEvents.ready, 1) + expect(dynamicThreadPool.hasTaskFunction(DEFAULT_TASK_NAME)).toBe(true) + expect(dynamicThreadPool.hasTaskFunction('jsonIntegerSerialization')).toBe( + true + ) + expect(dynamicThreadPool.hasTaskFunction('factorial')).toBe(true) + expect(dynamicThreadPool.hasTaskFunction('fibonacci')).toBe(true) + expect(dynamicThreadPool.hasTaskFunction('unknown')).toBe(false) + await dynamicThreadPool.destroy() + await fixedClusterPool.destroy() + }) + it('Verify that multiple task functions worker is working', async () => { const pool = new DynamicClusterPool( Math.floor(numberOfWorkers / 2),