2
2
mirror of https://github.com/octoleo/restic.git synced 2024-06-27 04:43:30 +00:00

Fix flaky worker cancel test

This commit is contained in:
Alexander Neumann 2016-05-09 20:41:55 +02:00
parent deae1e7e29
commit c6d934a685

View File

@ -94,7 +94,6 @@ var errCancelled = errors.New("cancelled")
type Job struct {
suc chan struct{}
d time.Duration
}
func wait(job worker.Job, done <-chan struct{}) (interface{}, error) {
@ -102,8 +101,6 @@ func wait(job worker.Job, done <-chan struct{}) (interface{}, error) {
select {
case j.suc <- struct{}{}:
return time.Now(), nil
case <-time.After(j.d):
return time.Now(), nil
case <-done:
return nil, errCancelled
}
@ -114,7 +111,7 @@ func TestPoolCancel(t *testing.T) {
suc := make(chan struct{}, 1)
for i := 0; i < 20; i++ {
jobCh <- worker.Job{Data: Job{suc: suc, d: time.Second}}
jobCh <- worker.Job{Data: Job{suc: suc}}
}
<-suc