X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=tests%2Fpools%2Fabstract%2Fabstract-pool.test.js;h=273de9a038f0a02eb0e4d554bd717107e06394f3;hb=a8884ffdad6658f854f4048d768f7e56cf8d5032;hp=4224f4ffe7a9e87bdc86169ef66a7b1437352c53;hpb=7fd82a1cb4d9d43e0f44333db35d3c4ad694e010;p=poolifier.git diff --git a/tests/pools/abstract/abstract-pool.test.js b/tests/pools/abstract/abstract-pool.test.js index 4224f4ff..273de9a0 100644 --- a/tests/pools/abstract/abstract-pool.test.js +++ b/tests/pools/abstract/abstract-pool.test.js @@ -9,14 +9,16 @@ const { describe('Abstract pool test suite', () => { const numberOfWorkers = 1 const workerNotFoundInTasksUsageMapError = new Error( - 'Worker could not be found in worker tasks usage map' + 'Worker could not be found in workers tasks usage map' ) - class StubPoolWithWorkerTasksUsageMapClear extends FixedThreadPool { + class StubPoolWithRemoveAllWorker extends FixedThreadPool { removeAllWorker () { + this.workers = [] this.workersTasksUsage.clear() + this.promiseMap.clear() } } - class StubPoolWithIsMainMethod extends FixedThreadPool { + class StubPoolWithIsMain extends FixedThreadPool { isMain () { return false } @@ -25,7 +27,7 @@ describe('Abstract pool test suite', () => { it('Simulate pool creation from a non main thread/process', () => { expect( () => - new StubPoolWithIsMainMethod( + new StubPoolWithIsMain( numberOfWorkers, './tests/worker-files/thread/testWorker.js', { @@ -116,7 +118,7 @@ describe('Abstract pool test suite', () => { }) it('Simulate worker not found during increaseWorkerRunningTasks', async () => { - const pool = new StubPoolWithWorkerTasksUsageMapClear( + const pool = new StubPoolWithRemoveAllWorker( numberOfWorkers, './tests/worker-files/cluster/testWorker.js' ) @@ -129,7 +131,7 @@ describe('Abstract pool test suite', () => { }) it('Simulate worker not found during decreaseWorkerRunningTasks', async () => { - const pool = new StubPoolWithWorkerTasksUsageMapClear( + const pool = new StubPoolWithRemoveAllWorker( numberOfWorkers, './tests/worker-files/cluster/testWorker.js', { @@ -145,7 +147,7 @@ describe('Abstract pool test suite', () => { }) it('Simulate worker not found during stepWorkerRunTasks', async () => { - const pool = new StubPoolWithWorkerTasksUsageMapClear( + const pool = new StubPoolWithRemoveAllWorker( numberOfWorkers, './tests/worker-files/cluster/testWorker.js', { @@ -161,7 +163,7 @@ describe('Abstract pool test suite', () => { }) it('Simulate worker not found during updateWorkerTasksRunTime with strategy not requiring it', async () => { - const pool = new StubPoolWithWorkerTasksUsageMapClear( + const pool = new StubPoolWithRemoveAllWorker( numberOfWorkers, './tests/worker-files/cluster/testWorker.js', { @@ -175,7 +177,7 @@ describe('Abstract pool test suite', () => { }) it('Simulate worker not found during updateWorkerTasksRunTime with strategy requiring it', async () => { - const pool = new StubPoolWithWorkerTasksUsageMapClear( + const pool = new StubPoolWithRemoveAllWorker( numberOfWorkers, './tests/worker-files/cluster/testWorker.js', {