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)
| 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. |
| 16 | func 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. |
nothing calls this directly
no test coverage detected
searching dependent graphs…