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

Function TestApp_releaseDefaultCtx_AbandonedSignalsReclaim

ctx_reclaim_test.go:141–155  ·  view source on GitHub ↗

TestApp_releaseDefaultCtx_AbandonedSignalsReclaim exercises the internal releaseDefaultCtx path (called by defaultRequestHandler's defer) for an abandoned, reclaim-armed context. It mirrors what ReleaseCtx does for the public CustomCtx path and ensures both release entry points fire the latch.

(t *testing.T)

Source from the content-addressed store, hash-verified

139// abandoned, reclaim-armed context. It mirrors what ReleaseCtx does for the
140// public CustomCtx path and ensures both release entry points fire the latch.
141func TestApp_releaseDefaultCtx_AbandonedSignalsReclaim(t *testing.T) {
142 t.Parallel()
143 app, c := acquireReclaimTestCtx(t)
144
145 handlerDone := make(chan struct{})
146 c.ScheduleReclaim(handlerDone, nil)
147
148 app.releaseDefaultCtx(c)
149 require.True(t, c.IsAbandoned(), "abandoned ctx must not be pooled by releaseDefaultCtx")
150
151 close(handlerDone)
152 require.Eventually(t, func() bool {
153 return !c.IsAbandoned()
154 }, time.Second, 5*time.Millisecond, "releaseDefaultCtx must wire signalReleased into the latch")
155}
156
157// TestApp_releaseDefaultCtx_NotAbandonedPools verifies the non-abandoned branch
158// in releaseDefaultCtx still pools the ctx through the normal path.

Callers

nothing calls this directly

Calls 4

acquireReclaimTestCtxFunction · 0.85
releaseDefaultCtxMethod · 0.80
ScheduleReclaimMethod · 0.65
IsAbandonedMethod · 0.65

Tested by

no test coverage detected