Skip to content

Commit

Permalink
test(storage): unflake TestIntegration_CancelWrite (#3691)
Browse files Browse the repository at this point in the history
Rarely a wrapped context.Cancel error can be returned from the
writer, so the current check will fail. We have to resort to string
matching for now, but for Go >= 1.13 errors.Is should work.

Fixes #3688
  • Loading branch information
tritone authored Feb 9, 2021
1 parent 8f4e130 commit 00a78aa
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions storage/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2558,12 +2558,14 @@ func TestIntegration_CancelWrite(t *testing.T) {
cancel()
// The next Write should return context.Canceled.
_, err = w.Write(buf)
if err != context.Canceled {
// TODO: Once we drop support for Go versions < 1.13, use errors.Is() to
// check for context cancellation instead.
if err != context.Canceled && !strings.Contains(err.Error(), "context canceled") {
t.Fatalf("got %v, wanted context.Canceled", err)
}
// The Close should too.
err = w.Close()
if err != context.Canceled {
if err != context.Canceled && !strings.Contains(err.Error(), "context canceled") {
t.Fatalf("got %v, wanted context.Canceled", err)
}
}
Expand Down

0 comments on commit 00a78aa

Please sign in to comment.