Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c9574c9
commit c891a9c
Showing
4 changed files
with
82 additions
and
32 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`workerPool should throw an error when worker.stdio is undefined 1`] = `"Failed to create the worker pool with workerId: 1 and configuration: {}. Please verify if you hit the OS open files limit."`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import childProcess from 'child_process'; | ||
import stream from 'stream'; | ||
import WorkerPool from '../src/WorkerPool'; | ||
|
||
jest.mock('child_process', () => { | ||
return { | ||
spawn: jest.fn(() => { | ||
return {}; | ||
}), | ||
}; | ||
}); | ||
|
||
describe('workerPool', () => { | ||
it('should throw an error when worker.stdio is undefined', () => { | ||
childProcess.spawn.mockImplementationOnce(() => { return {}; }); | ||
|
||
const workerPool = new WorkerPool({}); | ||
expect(() => workerPool.createWorker()).toThrowErrorMatchingSnapshot(); | ||
expect(() => workerPool.createWorker()).toThrowError('Please verify if you hit the OS open files limit'); | ||
}); | ||
|
||
it('should not throw an error when worker.stdio is defined', () => { | ||
childProcess.spawn.mockImplementationOnce(() => { | ||
return { | ||
stdio: new Array(5).fill(new stream.PassThrough()), | ||
}; | ||
}); | ||
|
||
const workerPool = new WorkerPool({}); | ||
expect(() => workerPool.createWorker()).not.toThrow(); | ||
}); | ||
}); |