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

Function TestContextAbortWithStatus

context_test.go:1817–1828  ·  view source on GitHub ↗

TestContextAbortWithStatus tests that the response can be written from `bytestring` with specified MIME type

(t *testing.T)

Source from the content-addressed store, hash-verified

1815// TestContextAbortWithStatus tests that the response can be written from `bytestring`
1816// with specified MIME type
1817func TestContextAbortWithStatus(t *testing.T) {
1818 w := httptest.NewRecorder()
1819 c, _ := CreateTestContext(w)
1820
1821 c.index = 4
1822 c.AbortWithStatus(http.StatusUnauthorized)
1823
1824 assert.Equal(t, abortIndex, c.index)
1825 assert.Equal(t, http.StatusUnauthorized, c.Writer.Status())
1826 assert.Equal(t, http.StatusUnauthorized, w.Code)
1827 assert.True(t, c.IsAborted())
1828}
1829
1830type testJSONAbortMsg struct {
1831 Foo string `json:"foo"`

Callers

nothing calls this directly

Calls 4

CreateTestContextFunction · 0.85
AbortWithStatusMethod · 0.80
IsAbortedMethod · 0.80
StatusMethod · 0.65

Tested by

no test coverage detected