X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=tests%2Fpools%2Fcluster%2Ffixed.test.js;h=f9423e731cbd93a20417b2124d7f4c4f4c8b783d;hb=21f710aa73abbb5d90328cfb199adfc0f7a70406;hp=60dac4017c72781b6b1e33a78169910438e3030a;hpb=eb7bf7441d410ca5d9ff9bb08f191ef22399371c;p=poolifier.git diff --git a/tests/pools/cluster/fixed.test.js b/tests/pools/cluster/fixed.test.js index 60dac401..f9423e73 100644 --- a/tests/pools/cluster/fixed.test.js +++ b/tests/pools/cluster/fixed.test.js @@ -1,7 +1,7 @@ const { expect } = require('expect') const { FixedClusterPool, PoolEvents } = require('../../../lib') const { WorkerFunctions } = require('../../test-types') -const TestUtils = require('../../test-utils') +const { waitWorkerEvents } = require('../../test-utils') describe('Fixed cluster pool test suite', () => { const numberOfWorkers = 6 @@ -74,7 +74,7 @@ describe('Fixed cluster pool test suite', () => { it('Verify that is possible to invoke the execute() method without input', async () => { const result = await pool.execute() - expect(result).toBe(false) + expect(result).toStrictEqual({ ok: 1 }) }) it("Verify that 'busy' event is emitted", async () => { @@ -145,8 +145,11 @@ describe('Fixed cluster pool test suite', () => { } expect(inError).toBeDefined() expect(typeof inError === 'string').toBe(true) - expect(inError).toContain('Error Message from ClusterWorker on worker') - expect(taskError.data).toStrictEqual(data) + expect(inError).toBe('Error Message from ClusterWorker') + expect(taskError).toStrictEqual({ + message: 'Error Message from ClusterWorker', + data + }) expect( errorPool.workerNodes.some( workerNode => workerNode.usage.tasks.failed === 1 @@ -168,10 +171,11 @@ describe('Fixed cluster pool test suite', () => { } expect(inError).toBeDefined() expect(typeof inError === 'string').toBe(true) - expect(inError).toContain( - 'Error Message from ClusterWorker:async on worker' - ) - expect(taskError.data).toStrictEqual(data) + expect(inError).toBe('Error Message from ClusterWorker:async') + expect(taskError).toStrictEqual({ + message: 'Error Message from ClusterWorker:async', + data + }) expect( asyncErrorPool.workerNodes.some( workerNode => workerNode.usage.tasks.failed === 1 @@ -189,11 +193,7 @@ describe('Fixed cluster pool test suite', () => { }) it('Shutdown test', async () => { - const exitPromise = TestUtils.waitWorkerEvents( - pool, - 'exit', - numberOfWorkers - ) + const exitPromise = waitWorkerEvents(pool, 'exit', numberOfWorkers) await pool.destroy() const numberOfExitEvents = await exitPromise expect(numberOfExitEvents).toBe(numberOfWorkers) @@ -228,7 +228,7 @@ describe('Fixed cluster pool test suite', () => { './tests/worker-files/cluster/testWorker.js' ) const res = await pool1.execute() - expect(res).toBe(false) + expect(res).toStrictEqual({ ok: 1 }) // We need to clean up the resources after our test await pool1.destroy() }) @@ -237,6 +237,6 @@ describe('Fixed cluster pool test suite', () => { expect( () => new FixedClusterPool(0, './tests/worker-files/cluster/testWorker.js') - ).toThrowError('Cannot instantiate a fixed pool with no worker') + ).toThrowError('Cannot instantiate a fixed pool with zero worker') }) })