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

Function TestContextGetCookie

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

Source from the content-addressed store, hash-verified

1020}
1021
1022func TestContextGetCookie(t *testing.T) {
1023 c, _ := CreateTestContext(httptest.NewRecorder())
1024 c.Request, _ = http.NewRequest(http.MethodGet, "/get", nil)
1025 c.Request.Header.Set("Cookie", "user=gin")
1026 cookie, _ := c.Cookie("user")
1027 assert.Equal(t, "gin", cookie)
1028
1029 _, err := c.Cookie("nokey")
1030 require.Error(t, err)
1031}
1032
1033func TestContextBodyAllowedForStatus(t *testing.T) {
1034 assert.False(t, bodyAllowedForStatus(http.StatusContinue))

Callers

nothing calls this directly

Calls 4

CreateTestContextFunction · 0.85
SetMethod · 0.80
CookieMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected