Skip to content

Commit

Permalink
Check for error in TestDo_panic
Browse files Browse the repository at this point in the history
Even the panic shoud prevent for reaching the error value
the error is checked for more visibility and linter warnings
  • Loading branch information
janos committed Jun 25, 2024
1 parent 9843622 commit 0f0311e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion singleflight_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,14 @@ func TestDo_panic(t *testing.T) {
recoveries <- recover()
}()

g.Do(ctx, "key", func(_ context.Context) (string, error) {
_, _, err := g.Do(ctx, "key", func(_ context.Context) (string, error) {
time.Sleep(200 * time.Millisecond)
panic(panicMessage)
})
t.Errorf("This line should not be reached - Do() should have panicked")
if err != nil {
t.Error(err)
}
}()
}

Expand Down

0 comments on commit 0f0311e

Please sign in to comment.