From 0f0311e849243d257f815d538138c5471c7cc66d Mon Sep 17 00:00:00 2001 From: Janos Guljas Date: Tue, 25 Jun 2024 10:54:13 +0200 Subject: [PATCH] Check for error in TestDo_panic Even the panic shoud prevent for reaching the error value the error is checked for more visibility and linter warnings --- singleflight_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/singleflight_test.go b/singleflight_test.go index 40d752b..2d585f5 100644 --- a/singleflight_test.go +++ b/singleflight_test.go @@ -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) + } }() }