77import _ from 'lodash' ;
88import sinon from 'sinon' ;
99import { fillPool } from './fill_pool' ;
10+ import { TaskPoolRunResult } from '../task_pool' ;
1011
1112describe ( 'fillPool' , ( ) => {
1213 test ( 'stops filling when there are no more tasks in the store' , async ( ) => {
1314 const tasks = [ [ 1 , 2 , 3 ] , [ 4 , 5 ] ] ;
1415 let index = 0 ;
1516 const fetchAvailableTasks = async ( ) => tasks [ index ++ ] || [ ] ;
16- const run = sinon . spy ( async ( ) => true ) ;
17+ const run = sinon . spy ( async ( ) => TaskPoolRunResult . RunningAllClaimedTasks ) ;
1718 const converter = _ . identity ;
1819
1920 await fillPool ( run , fetchAvailableTasks , converter ) ;
@@ -25,7 +26,7 @@ describe('fillPool', () => {
2526 const tasks = [ [ 1 , 2 , 3 ] , [ 4 , 5 ] ] ;
2627 let index = 0 ;
2728 const fetchAvailableTasks = async ( ) => tasks [ index ++ ] || [ ] ;
28- const run = sinon . spy ( async ( ) => false ) ;
29+ const run = sinon . spy ( async ( ) => TaskPoolRunResult . RanOutOfCapacity ) ;
2930 const converter = _ . identity ;
3031
3132 await fillPool ( run , fetchAvailableTasks , converter ) ;
@@ -37,7 +38,7 @@ describe('fillPool', () => {
3738 const tasks = [ [ 1 , 2 , 3 ] , [ 4 , 5 ] ] ;
3839 let index = 0 ;
3940 const fetchAvailableTasks = async ( ) => tasks [ index ++ ] || [ ] ;
40- const run = sinon . spy ( async ( ) => false ) ;
41+ const run = sinon . spy ( async ( ) => TaskPoolRunResult . RanOutOfCapacity ) ;
4142 const converter = ( x : number ) => x . toString ( ) ;
4243
4344 await fillPool ( run , fetchAvailableTasks , converter ) ;
@@ -47,7 +48,7 @@ describe('fillPool', () => {
4748
4849 describe ( 'error handling' , ( ) => {
4950 test ( 'throws exception from fetchAvailableTasks' , async ( ) => {
50- const run = sinon . spy ( async ( ) => false ) ;
51+ const run = sinon . spy ( async ( ) => TaskPoolRunResult . RanOutOfCapacity ) ;
5152 const converter = ( x : number ) => x . toString ( ) ;
5253
5354 try {
@@ -80,7 +81,7 @@ describe('fillPool', () => {
8081 const tasks = [ [ 1 , 2 , 3 ] , [ 4 , 5 ] ] ;
8182 let index = 0 ;
8283 const fetchAvailableTasks = async ( ) => tasks [ index ++ ] || [ ] ;
83- const run = sinon . spy ( async ( ) => false ) ;
84+ const run = sinon . spy ( async ( ) => TaskPoolRunResult . RanOutOfCapacity ) ;
8485 const converter = ( x : number ) => {
8586 throw new Error ( `can not convert ${ x } ` ) ;
8687 } ;
0 commit comments