MCPcopy
hub / github.com/keploy/keploy / TestDrainErrGroupReturnsError

Function TestDrainErrGroupReturnsError

utils/drain_test.go:15–28  ·  view source on GitHub ↗

TestDrainErrGroupReturnsError verifies the normal path: when the group's goroutines finish before the timeout, DrainErrGroup returns g.Wait()'s error verbatim (and does not wait out the timeout).

(t *testing.T)

Source from the content-addressed store, hash-verified

13// goroutines finish before the timeout, DrainErrGroup returns g.Wait()'s error
14// verbatim (and does not wait out the timeout).
15func TestDrainErrGroupReturnsError(t *testing.T) {
16 var g errgroup.Group
17 want := errors.New("boom")
18 g.Go(func() error { return want })
19
20 start := time.Now()
21 got := DrainErrGroup(zap.NewNop(), "test", &g, time.Second)
22 if !errors.Is(got, want) {
23 t.Fatalf("DrainErrGroup err = %v, want %v", got, want)
24 }
25 if elapsed := time.Since(start); elapsed > 500*time.Millisecond {
26 t.Fatalf("DrainErrGroup blocked for %s on a fast group; should return immediately", elapsed)
27 }
28}
29
30// TestDrainErrGroupTimesOutOnHang is the regression guard for the shutdown
31// deadlock: a goroutine that ignores cancellation (here, blocks forever) must

Callers

nothing calls this directly

Calls 2

DrainErrGroupFunction · 0.85
NewMethod · 0.65

Tested by

no test coverage detected