From: Jérôme Benoit Date: Wed, 20 Sep 2023 20:17:00 +0000 (+0200) Subject: refactor: check for worker file existence first X-Git-Tag: v2.7.2~24 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=8003c02697fa03f1d40578ae9177150de22d25a2;p=poolifier.git refactor: check for worker file existence first Signed-off-by: Jérôme Benoit --- diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index e525cc9a..70459dbb 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -133,8 +133,8 @@ export abstract class AbstractPool< 'Cannot start a pool from a worker with the same type as the pool' ) } - this.checkNumberOfWorkers(this.numberOfWorkers) checkFilePath(this.filePath) + this.checkNumberOfWorkers(this.numberOfWorkers) this.checkPoolOptions(this.opts) this.chooseWorkerNode = this.chooseWorkerNode.bind(this) diff --git a/tests/pools/abstract-pool.test.js b/tests/pools/abstract-pool.test.js index 3860a0eb..85d48d6a 100644 --- a/tests/pools/abstract-pool.test.js +++ b/tests/pools/abstract-pool.test.js @@ -79,7 +79,13 @@ describe('Abstract pool test suite', () => { }) it('Verify that numberOfWorkers is checked', () => { - expect(() => new FixedThreadPool()).toThrowError( + expect( + () => + new FixedThreadPool( + undefined, + './tests/worker-files/thread/testWorker.js' + ) + ).toThrowError( new Error( 'Cannot instantiate a pool without specifying the number of workers' )