X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=tests%2Fpools%2Fthread%2Ffixed.test.js;h=755ccf4d4fa2aa12b0621344d1010af377431248;hb=6fdc721bfdc82852c19cf4d53e0918c9665a580f;hp=ec6a066bf8c0042cc2ff21a7e9345f87416b72a9;hpb=515e5da7461f84786a9b6acf859cf65a083e2f4c;p=poolifier.git diff --git a/tests/pools/thread/fixed.test.js b/tests/pools/thread/fixed.test.js index ec6a066b..755ccf4d 100644 --- a/tests/pools/thread/fixed.test.js +++ b/tests/pools/thread/fixed.test.js @@ -1,20 +1,25 @@ const expect = require('expect') const { FixedThreadPool } = require('../../../lib/index') -const numThreads = 10 +const numberOfThreads = 10 const maxTasks = 400 const pool = new FixedThreadPool( - numThreads, - './tests/worker/thread/testWorker.js', + numberOfThreads, + './tests/worker-files/thread/testWorker.js', { - errorHandler: e => console.error(e), - onlineHandler: () => console.log('worker is online') + errorHandler: e => console.error(e) } ) -const emptyPool = new FixedThreadPool(1, './tests/worker/thread/emptyWorker.js') -const echoPool = new FixedThreadPool(1, './tests/worker/thread/echoWorker.js') +const emptyPool = new FixedThreadPool( + 1, + './tests/worker-files/thread/emptyWorker.js' +) +const echoPool = new FixedThreadPool( + 1, + './tests/worker-files/thread/echoWorker.js' +) const errorPool = new FixedThreadPool( 1, - './tests/worker/thread/errorWorker.js', + './tests/worker-files/thread/errorWorker.js', { errorHandler: e => console.error(e), onlineHandler: () => console.log('worker is online') @@ -22,17 +27,17 @@ const errorPool = new FixedThreadPool( ) const asyncPool = new FixedThreadPool( 1, - './tests/worker/thread/asyncWorker.js', + './tests/worker-files/thread/asyncWorker.js', { maxTasks: maxTasks } ) describe('Fixed thread pool test suite ', () => { it('Choose worker round robin test', async () => { const results = new Set() - for (let i = 0; i < numThreads; i++) { + for (let i = 0; i < numberOfThreads; i++) { results.add(pool.chooseWorker().threadId) } - expect(results.size).toBe(numThreads) + expect(results.size).toBe(numberOfThreads) }) it('Verify that the function is executed in a worker thread', async () => { @@ -95,7 +100,7 @@ describe('Fixed thread pool test suite ', () => { }) }) await pool.destroy() - expect(closedThreads).toBe(numThreads) + expect(closedThreads).toBe(numberOfThreads) }) it('Validations test', () => { @@ -111,7 +116,10 @@ describe('Fixed thread pool test suite ', () => { }) it('Should work even without opts in input', async () => { - const pool1 = new FixedThreadPool(1, './tests/worker/thread/testWorker.js') + const pool1 = new FixedThreadPool( + 1, + './tests/worker-files/thread/testWorker.js' + ) const res = await pool1.execute({ test: 'test' }) expect(res).toBeFalsy() })