test: ensure consistency of TestSpooler_awaitError (#3750)

This commit is contained in:
Livio Spring 2022-06-07 13:40:46 +02:00 committed by GitHub
parent 233d80502d
commit ace94917da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -224,12 +224,17 @@ func TestSpooler_awaitError(t *testing.T) {
s := &spooledHandler{
Handler: tt.fields.currentHandler,
}
c := make(chan interface{})
errs := make(chan error)
ctx, cancel := context.WithCancel(context.Background())
go s.awaitError(cancel, errs, "test")
go func() {
s.awaitError(cancel, errs, "test")
c <- nil
}()
errs <- tt.fields.err
<-c
if ctx.Err() == nil {
t.Error("cancel function was not called")
}