Skip to content

Commit

Permalink
chore: add ContextRenderRedirectWithEmptyPath test case
Browse files Browse the repository at this point in the history
  • Loading branch information
RedCrazyGhost committed Jul 13, 2024
1 parent c99d328 commit 8adb690
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,18 @@ func TestContextRenderRedirectWith201(t *testing.T) {
assert.Equal(t, "/resource", w.Header().Get("Location"))
}

func TestContextRenderRedirectWithEmptyPath(t *testing.T) {
w := httptest.NewRecorder()
c, _ := CreateTestContext(w)

c.Request, _ = http.NewRequest("POST", "http://example.com", nil)
c.Redirect(http.StatusTemporaryRedirect, "")
c.Writer.WriteHeaderNow()

assert.Equal(t, http.StatusTemporaryRedirect, w.Code)
assert.Equal(t, "/", w.Header().Get("Location"))
}

func TestContextRenderRedirectAll(t *testing.T) {
c, _ := CreateTestContext(httptest.NewRecorder())
c.Request, _ = http.NewRequest("POST", "http://example.com", nil)
Expand Down

0 comments on commit 8adb690

Please sign in to comment.