Skip to content

Commit

Permalink
🩹 Fix: i/o timout in Test_Proxy_Do_WithRealURL
Browse files Browse the repository at this point in the history
  • Loading branch information
JIeJaitt committed Feb 25, 2025
1 parent ea11d43 commit e2ad63e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions middleware/proxy/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,18 +501,24 @@ func Test_Proxy_Do_RestoreOriginalURL(t *testing.T) {
// go test -race -run Test_Proxy_Do_WithRealURL
func Test_Proxy_Do_WithRealURL(t *testing.T) {
t.Parallel()

_, addr := createProxyTestServerIPv4(t, func(c fiber.Ctx) error {
return c.SendString("mock response")
})

app := fiber.New()
app.Get("/test", func(c fiber.Ctx) error {
return Do(c, "https://www.google.com")
return Do(c, "http://"+addr)
})

resp, err1 := app.Test(httptest.NewRequest(fiber.MethodGet, "/test", nil))
require.NoError(t, err1)
resp, err := app.Test(httptest.NewRequest(fiber.MethodGet, "/test", nil))
require.NoError(t, err)
require.Equal(t, fiber.StatusOK, resp.StatusCode)
require.Equal(t, "/test", resp.Request.URL.String())

body, err := io.ReadAll(resp.Body)
require.NoError(t, err)
require.Contains(t, string(body), "https://www.google.com/")
require.Equal(t, "mock response", string(body))
}

// go test -race -run Test_Proxy_Do_WithRedirect
Expand Down

0 comments on commit e2ad63e

Please sign in to comment.