MCPcopy
hub / github.com/gofiber/fiber / TestDefaultCtx_ScheduleReclaim_HappyPath

Function TestDefaultCtx_ScheduleReclaim_HappyPath

ctx_reclaim_test.go:32–47  ·  view source on GitHub ↗

TestDefaultCtx_ScheduleReclaim_HappyPath covers the dominant timed-out flow: after ScheduleReclaim is armed and both signals fire (handlerDone closes and the request handler releases the context), the context is returned to the pool, observable as IsAbandoned flipping back to false.

(t *testing.T)

Source from the content-addressed store, hash-verified

30// the request handler releases the context), the context is returned to the
31// pool, observable as IsAbandoned flipping back to false.
32func TestDefaultCtx_ScheduleReclaim_HappyPath(t *testing.T) {
33 t.Parallel()
34 app, c := acquireReclaimTestCtx(t)
35
36 handlerDone := make(chan struct{})
37 c.ScheduleReclaim(handlerDone, nil)
38 require.True(t, c.IsAbandoned(), "ScheduleReclaim must Abandon the ctx internally")
39
40 close(handlerDone)
41 require.True(t, c.IsAbandoned(), "ctx must stay abandoned until ReleaseCtx fires")
42
43 app.ReleaseCtx(c)
44 require.Eventually(t, func() bool {
45 return !c.IsAbandoned()
46 }, time.Second, 5*time.Millisecond, "ctx must be reclaimed once both signals fire")
47}
48
49// TestDefaultCtx_ScheduleReclaim_ReleaseBeforeHandlerDone covers the reverse
50// ordering: ReleaseCtx is called first, then handlerDone closes. The reclaim

Callers

nothing calls this directly

Calls 4

acquireReclaimTestCtxFunction · 0.85
ReleaseCtxMethod · 0.80
ScheduleReclaimMethod · 0.65
IsAbandonedMethod · 0.65

Tested by

no test coverage detected