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

Function TestContextAbortWithError

context_test.go:1936–1945  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1934}
1935
1936func TestContextAbortWithError(t *testing.T) {
1937 w := httptest.NewRecorder()
1938 c, _ := CreateTestContext(w)
1939
1940 c.AbortWithError(http.StatusUnauthorized, errors.New("bad input")).SetMeta("some input") //nolint: errcheck
1941
1942 assert.Equal(t, http.StatusUnauthorized, w.Code)
1943 assert.Equal(t, abortIndex, c.index)
1944 assert.True(t, c.IsAborted())
1945}
1946
1947func TestContextClientIP(t *testing.T) {
1948 c, _ := CreateTestContext(httptest.NewRecorder())

Callers

nothing calls this directly

Calls 4

CreateTestContextFunction · 0.85
SetMetaMethod · 0.80
AbortWithErrorMethod · 0.80
IsAbortedMethod · 0.80

Tested by

no test coverage detected