Skip to content

Commit b0a3bae

Browse files
test: add coverage for Go-after-Wait misuse panic
1 parent 68caee0 commit b0a3bae

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

internal/sync/errgroup_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,26 @@ func Test_ErrGroup_FirstError(t *testing.T) {
4848
require.NoError(t, err)
4949
}
5050

51+
func Test_ErrGroup_GoAfterWait_Panics(t *testing.T) {
52+
s := NewScheduler()
53+
ctx := Background()
54+
55+
s.NewCoroutine(ctx, func(ctx Context) error {
56+
gctx, g := WithErrGroup(ctx)
57+
58+
g.Go(func(ctx Context) error { return nil })
59+
_ = g.Wait(gctx)
60+
61+
require.Panics(t, func() {
62+
g.Go(func(ctx Context) error { return nil })
63+
})
64+
return nil
65+
})
66+
67+
err := s.Execute()
68+
require.NoError(t, err)
69+
}
70+
5171
func Test_ErrGroup_MultipleErrors_FirstWins(t *testing.T) {
5272
s := NewScheduler()
5373
ctx := Background()

0 commit comments

Comments
 (0)