From 8003c02697fa03f1d40578ae9177150de22d25a2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Wed, 20 Sep 2023 22:17:00 +0200 Subject: [PATCH] refactor: check for worker file existence first MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/pools/abstract-pool.ts | 2 +- tests/pools/abstract-pool.test.js | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) 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' ) -- 2.34.1