}
if (
workerChoiceStrategyOptions.choiceRetries != null &&
- workerChoiceStrategyOptions.choiceRetries <= 0
+ workerChoiceStrategyOptions.choiceRetries < 0
) {
throw new RangeError(
- `Invalid worker choice strategy options: choice retries '${workerChoiceStrategyOptions.choiceRetries}' must be greater than zero`
+ `Invalid worker choice strategy options: choice retries '${workerChoiceStrategyOptions.choiceRetries}' must be greater or equal than zero`
)
}
if (
).toThrowError(
new Error("Invalid worker choice strategy 'invalidStrategy'")
)
+ expect(
+ () =>
+ new FixedThreadPool(
+ numberOfWorkers,
+ './tests/worker-files/thread/testWorker.js',
+ {
+ workerChoiceStrategyOptions: {
+ choiceRetries: 'invalidChoiceRetries'
+ }
+ }
+ )
+ ).toThrowError(
+ new TypeError(
+ 'Invalid worker choice strategy options: choice retries must be an integer'
+ )
+ )
+ expect(
+ () =>
+ new FixedThreadPool(
+ numberOfWorkers,
+ './tests/worker-files/thread/testWorker.js',
+ {
+ workerChoiceStrategyOptions: {
+ choiceRetries: -1
+ }
+ }
+ )
+ ).toThrowError(
+ new RangeError(
+ "Invalid worker choice strategy options: choice retries '-1' must be greater or equal than zero"
+ )
+ )
expect(
() =>
new FixedThreadPool(
'Invalid worker choice strategy options: must be a plain object'
)
)
+ expect(() =>
+ pool.setWorkerChoiceStrategyOptions({
+ choiceRetries: 'invalidChoiceRetries'
+ })
+ ).toThrowError(
+ new TypeError(
+ 'Invalid worker choice strategy options: choice retries must be an integer'
+ )
+ )
+ expect(() =>
+ pool.setWorkerChoiceStrategyOptions({ choiceRetries: -1 })
+ ).toThrowError(
+ new RangeError(
+ "Invalid worker choice strategy options: choice retries '-1' must be greater or equal than zero"
+ )
+ )
expect(() =>
pool.setWorkerChoiceStrategyOptions({ weights: {} })
).toThrowError(