MCPcopy
hub / github.com/gofiber/fiber / Test_Proxy_Do_WithRealURL

Function Test_Proxy_Do_WithRealURL

middleware/proxy/proxy_test.go:569–591  ·  view source on GitHub ↗

go test -race -run Test_Proxy_Do_WithRealURL

(t *testing.T)

Source from the content-addressed store, hash-verified

567
568// go test -race -run Test_Proxy_Do_WithRealURL
569func 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
594func Test_Proxy_Do_WithRedirect(t *testing.T) {

Callers

nothing calls this directly

Calls 7

DoFunction · 0.85
TestMethod · 0.80
SendStringMethod · 0.65
NewMethod · 0.65
GetMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected