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

Function Test_Proxy_Balancer_Forward_Local

middleware/proxy/proxy_test.go:1013–1032  ·  view source on GitHub ↗

go test -run Test_Proxy_Balancer_Forward_Local

(t *testing.T)

Source from the content-addressed store, hash-verified

1011
1012// go test -run Test_Proxy_Balancer_Forward_Local
1013func Test_Proxy_Balancer_Forward_Local(t *testing.T) {
1014 t.Parallel()
1015
1016 app := fiber.New()
1017
1018 _, addr := createProxyTestServerIPv4(t, func(c fiber.Ctx) error {
1019 return c.SendString("forwarded")
1020 })
1021
1022 app.Use(BalancerForward([]string{addr}))
1023
1024 resp, err := app.Test(httptest.NewRequest(fiber.MethodGet, "/", http.NoBody))
1025 require.NoError(t, err)
1026 require.Equal(t, fiber.StatusOK, resp.StatusCode)
1027
1028 b, err := io.ReadAll(resp.Body)
1029 require.NoError(t, err)
1030
1031 require.Equal(t, "forwarded", string(b))
1032}
1033
1034// go test -run Test_Proxy_Balancer_Forward_Empty_Servers
1035func Test_Proxy_Balancer_Forward_Empty_Servers(t *testing.T) {

Callers

nothing calls this directly

Calls 6

BalancerForwardFunction · 0.85
TestMethod · 0.80
NewMethod · 0.65
SendStringMethod · 0.65
UseMethod · 0.65

Tested by

no test coverage detected