forked from TrueCloudLab/restic
Fix flaky worker cancel test
This commit is contained in:
parent
deae1e7e29
commit
c6d934a685
1 changed files with 1 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue