From 7fee13ac1087f490ea8883ea56351fcaaa0acc5d Mon Sep 17 00:00:00 2001 From: Lz Date: Tue, 24 Dec 2024 16:47:27 +0800 Subject: [PATCH] fix(tests): only disabled to follow redirect on Redirect test --- app_test.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app_test.go b/app_test.go index d460602..97a86b0 100644 --- a/app_test.go +++ b/app_test.go @@ -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()) } @@ -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"))