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

Function TestContextRenderRedirectWith201

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

Source from the content-addressed store, hash-verified

1577}
1578
1579func TestContextRenderRedirectWith201(t *testing.T) {
1580 w := httptest.NewRecorder()
1581 c, _ := CreateTestContext(w)
1582
1583 c.Request, _ = http.NewRequest(http.MethodPost, "http://example.com", nil)
1584 c.Redirect(http.StatusCreated, "/resource")
1585 c.Writer.WriteHeaderNow()
1586
1587 assert.Equal(t, http.StatusCreated, w.Code)
1588 assert.Equal(t, "/resource", w.Header().Get("Location"))
1589}
1590
1591func TestContextRenderRedirectAll(t *testing.T) {
1592 c, _ := CreateTestContext(httptest.NewRecorder())

Callers

nothing calls this directly

Calls 5

CreateTestContextFunction · 0.85
RedirectMethod · 0.80
WriteHeaderNowMethod · 0.65
GetMethod · 0.45
HeaderMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…