MCPcopy
hub / github.com/gin-gonic/gin / TestContextReset

Function TestContextReset

context_test.go:277–298  ·  context_test.go::TestContextReset
(t *testing.T)

Source from the content-addressed store, hash-verified

275}
276
277func TestContextReset(t *testing.T) {
278 router := New()
279 c := router.allocateContext(0)
280 assert.Equal(t, c.engine, router)
281
282 c.index = 2
283 c.Writer = &responseWriter{ResponseWriter: httptest.NewRecorder()}
284 c.Params = Params{Param{}}
285 c.Error(errors.New("test")) //nolint: errcheck
286 c.Set("foo", "bar")
287 c.reset()
288
289 assert.False(t, c.IsAborted())
290 assert.Nil(t, c.Keys)
291 assert.Nil(t, c.Accepted)
292 assert.Empty(t, c.Errors)
293 assert.Empty(t, c.Errors.Errors())
294 assert.Empty(t, c.Errors.ByType(ErrorTypeAny))
295 assert.Empty(t, c.Params)
296 assert.EqualValues(t, -1, c.index)
297 assert.Equal(t, c.Writer.(*responseWriter), &c.writermem)
298}
299
300func TestContextHandlers(t *testing.T) {
301 c, _ := CreateTestContext(httptest.NewRecorder())

Callers

nothing calls this directly

Calls 8

NewFunction · 0.85
allocateContextMethod · 0.80
SetMethod · 0.80
IsAbortedMethod · 0.80
ErrorsMethod · 0.80
ByTypeMethod · 0.80
ErrorMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected