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

Function TestDefaultCtx_ScheduleReclaim_CancelInvoked

ctx_reclaim_test.go:70–86  ·  view source on GitHub ↗

TestDefaultCtx_ScheduleReclaim_CancelInvoked verifies the cancel hook fires exactly once when the handler goroutine finishes.

(t *testing.T)

Source from the content-addressed store, hash-verified

68// TestDefaultCtx_ScheduleReclaim_CancelInvoked verifies the cancel hook fires
69// exactly once when the handler goroutine finishes.
70func TestDefaultCtx_ScheduleReclaim_CancelInvoked(t *testing.T) {
71 t.Parallel()
72 app, c := acquireReclaimTestCtx(t)
73
74 var calls atomic.Int32
75 cancel := func() { calls.Add(1) }
76
77 handlerDone := make(chan struct{})
78 c.ScheduleReclaim(handlerDone, cancel)
79
80 close(handlerDone)
81 app.ReleaseCtx(c)
82
83 require.Eventually(t, func() bool {
84 return calls.Load() == 1 && !c.IsAbandoned()
85 }, time.Second, 5*time.Millisecond, "cancel must fire once and ctx must be reclaimed")
86}
87
88// TestDefaultCtx_ScheduleReclaim_NilCancel exercises the cancel==nil branch.
89func TestDefaultCtx_ScheduleReclaim_NilCancel(t *testing.T) {

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected