2
2
mirror of https://github.com/octoleo/restic.git synced 2024-06-26 12:32:36 +00:00

Remove flaky test

This commit is contained in:
Alexander Neumann 2016-08-28 21:06:27 +02:00
parent f9cd736b33
commit dec2e4788e

View File

@ -3,7 +3,6 @@ package worker_test
import (
"errors"
"testing"
"time"
"restic/worker"
)
@ -89,60 +88,3 @@ func TestPoolErrors(t *testing.T) {
}
}
}
var errCancelled = errors.New("cancelled")
type Job struct {
suc chan struct{}
}
func TestPoolCancel(t *testing.T) {
barrier := make(chan struct{})
sendTime := func(job worker.Job, done <-chan struct{}) (interface{}, error) {
j := job.Data.(Job)
<-barrier
select {
case j.suc <- struct{}{}:
return time.Now(), nil
case <-done:
return nil, errCancelled
}
}
jobCh, resCh, p := newBufferedPool(20, concurrency, sendTime)
suc := make(chan struct{})
for i := 0; i < 20; i++ {
jobCh <- worker.Job{Data: Job{suc: suc}}
}
close(barrier)
for i := 0; i < 10; i++ {
<-suc
}
p.Cancel()
p.Wait()
foundResult := false
foundCancelError := false
for res := range resCh {
if res.Error == nil {
foundResult = true
}
if res.Error == errCancelled {
foundCancelError = true
}
}
if !foundResult {
t.Error("did not find one expected result")
}
if !foundCancelError {
t.Error("did not find one expected cancel error")
}
}