MCPcopy
hub / github.com/labstack/echo / TestContextResetClearsStore

Function TestContextResetClearsStore

dispatch_pool_test.go:16–27  ·  view source on GitHub ↗

TestContextResetClearsStore guards the clear(c.store) reuse: a pooled Context must not leak store values from a previous request into the next one, and Set must still work after a clear-based Reset.

(t *testing.T)

Source from the content-addressed store, hash-verified

14// TestContextResetClearsStore guards the clear(c.store) reuse: a pooled Context must not leak store
15// values from a previous request into the next one, and Set must still work after a clear-based Reset.
16func TestContextResetClearsStore(t *testing.T) {
17 e := New()
18 c := e.NewContext(httptest.NewRequest(http.MethodGet, "/", nil), httptest.NewRecorder())
19 c.Set("secret", "req1")
20 assert.Equal(t, "req1", c.Get("secret"))
21
22 c.Reset(httptest.NewRequest(http.MethodGet, "/", nil), httptest.NewRecorder())
23 assert.Nil(t, c.Get("secret"), "store must not leak across Reset")
24
25 c.Set("k", "req2") // Set must still work after clear-based reset
26 assert.Equal(t, "req2", c.Get("k"))
27}
28
29// TestContextJSONStatusAcrossReset guards the reused delayedStatusWriter (c.dsw): a second JSON
30// response on a pooled+Reset Context must use the new status, not inherit the previous one.

Callers

nothing calls this directly

Calls 5

SetMethod · 0.95
GetMethod · 0.95
ResetMethod · 0.95
NewFunction · 0.85
NewContextMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…