go test -race -run Test_Proxy_Do_WithRealURL
(t *testing.T)
| 567 | |
| 568 | // go test -race -run Test_Proxy_Do_WithRealURL |
| 569 | func Test_Proxy_Do_WithRealURL(t *testing.T) { |
| 570 | t.Parallel() |
| 571 | |
| 572 | _, addr := createProxyTestServerIPv4(t, func(c fiber.Ctx) error { |
| 573 | return c.SendString("real url") |
| 574 | }) |
| 575 | |
| 576 | app := fiber.New() |
| 577 | app.Get("/test", func(c fiber.Ctx) error { |
| 578 | return Do(c, "http://"+addr) |
| 579 | }) |
| 580 | |
| 581 | resp, err1 := app.Test(httptest.NewRequest(fiber.MethodGet, "/test", http.NoBody), fiber.TestConfig{ |
| 582 | Timeout: 2 * time.Second, |
| 583 | FailOnTimeout: true, |
| 584 | }) |
| 585 | require.NoError(t, err1) |
| 586 | require.Equal(t, fiber.StatusOK, resp.StatusCode) |
| 587 | require.Equal(t, "/test", resp.Request.URL.String()) |
| 588 | body, err := io.ReadAll(resp.Body) |
| 589 | require.NoError(t, err) |
| 590 | require.Equal(t, "real url", string(body)) |
| 591 | } |
| 592 | |
| 593 | // go test -race -run Test_Proxy_Do_WithRedirect |
| 594 | func Test_Proxy_Do_WithRedirect(t *testing.T) { |
nothing calls this directly
no test coverage detected