From: Jérôme Benoit Date: Mon, 2 Oct 2023 17:13:51 +0000 (+0200) Subject: test: cleanup worker error tests X-Git-Tag: v2.7.5~5 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=18ecc6c58fb5ba2e28b874b47980089351b5674f;p=poolifier.git test: cleanup worker error tests Signed-off-by: Jérôme Benoit --- diff --git a/tests/worker/abstract-worker.test.mjs b/tests/worker/abstract-worker.test.mjs index 9058790b..11bf6927 100644 --- a/tests/worker/abstract-worker.test.mjs +++ b/tests/worker/abstract-worker.test.mjs @@ -200,15 +200,6 @@ describe('Abstract worker test suite', () => { expect(killHandlerStub.calledOnce).toBe(true) }) - it('Verify that handleError() method is working properly', () => { - const error = new Error('Error as an error') - const worker = new ClusterWorker(() => {}) - expect(worker.handleError(error)).not.toBeInstanceOf(Error) - expect(worker.handleError(error)).toStrictEqual(error.message) - const errorMessage = 'Error as a string' - expect(worker.handleError(errorMessage)).toStrictEqual(errorMessage) - }) - it('Verify that getMainWorker() throw error if main worker is not set', () => { expect(() => new StubWorkerWithMainWorker(() => {}).getMainWorker() diff --git a/tests/worker/cluster-worker.test.mjs b/tests/worker/cluster-worker.test.mjs index ea6a0481..f6a927aa 100644 --- a/tests/worker/cluster-worker.test.mjs +++ b/tests/worker/cluster-worker.test.mjs @@ -12,6 +12,15 @@ describe('Cluster worker test suite', () => { } } + it('Verify that handleError() method is working properly', () => { + const error = new Error('Error as an error') + const worker = new ClusterWorker(() => {}) + expect(worker.handleError(error)).not.toBeInstanceOf(Error) + expect(worker.handleError(error)).toStrictEqual(error.message) + const errorMessage = 'Error as a string' + expect(worker.handleError(errorMessage)).toStrictEqual(errorMessage) + }) + it('Verify worker invokes the getMainWorker() and send() methods', () => { const worker = new SpyWorker(() => {}) worker.sendToMainWorker({ ok: 1 }) diff --git a/tests/worker/thread-worker.test.mjs b/tests/worker/thread-worker.test.mjs index 8b6f9c79..4be262a2 100644 --- a/tests/worker/thread-worker.test.mjs +++ b/tests/worker/thread-worker.test.mjs @@ -16,6 +16,7 @@ describe('Thread worker test suite', () => { it('Verify that handleError() method is working properly', () => { const error = new Error('Error as an error') const worker = new ThreadWorker(() => {}) + expect(worker.handleError(error)).toBeInstanceOf(Error) expect(worker.handleError(error)).toStrictEqual(error) const errorMessage = 'Error as a string' expect(worker.handleError(errorMessage)).toStrictEqual(errorMessage)