Skip to content

Commit

Permalink
fix(tests): only disabled to follow redirect on Redirect test
Browse files Browse the repository at this point in the history
  • Loading branch information
cnlangzi committed Dec 24, 2024
1 parent e3bd655 commit 7fee13a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ func TestMain(m *testing.M) {
}
client = http.Client{
Transport: tr,
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
},
}
os.Exit(m.Run())
}
Expand Down Expand Up @@ -211,9 +208,15 @@ func TestStatus(t *testing.T) {
require.Equal(t, http.StatusInternalServerError, resp.StatusCode)
resp.Body.Close()

c := http.Client{
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
},
}

req, err = http.NewRequest("GET", srv.URL+"/302", nil)
require.NoError(t, err)
resp, err = client.Do(req)
resp, err = c.Do(req)
require.NoError(t, err)
require.Equal(t, http.StatusMovedPermanently, resp.StatusCode)
require.Equal(t, "http://127.0.0.1/redirect", resp.Header.Get("Location"))
Expand Down

0 comments on commit 7fee13a

Please sign in to comment.