Fix flaky test

This commit is contained in:
Alexander Neumann 2016-08-28 21:04:35 +02:00
parent 553dd00741
commit f9cd736b33

View file

@ -99,7 +99,7 @@ type Job struct {
func TestPoolCancel(t *testing.T) { func TestPoolCancel(t *testing.T) {
barrier := make(chan struct{}) barrier := make(chan struct{})
wait := func(job worker.Job, done <-chan struct{}) (interface{}, error) { sendTime := func(job worker.Job, done <-chan struct{}) (interface{}, error) {
j := job.Data.(Job) j := job.Data.(Job)
<-barrier <-barrier
@ -112,7 +112,7 @@ func TestPoolCancel(t *testing.T) {
} }
} }
jobCh, resCh, p := newBufferedPool(20, concurrency, wait) jobCh, resCh, p := newBufferedPool(20, concurrency, sendTime)
suc := make(chan struct{}) suc := make(chan struct{})
for i := 0; i < 20; i++ { for i := 0; i < 20; i++ {
@ -120,7 +120,9 @@ func TestPoolCancel(t *testing.T) {
} }
close(barrier) close(barrier)
for i := 0; i < 10; i++ {
<-suc <-suc
}
p.Cancel() p.Cancel()
p.Wait() p.Wait()