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

Function Test_Replace

client/client_test.go:2016–2049  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2014}
2015
2016func Test_Replace(t *testing.T) {
2017 app, dial, start := createHelperServer(t)
2018
2019 app.Get("/", func(c fiber.Ctx) error {
2020 return c.SendString(string(c.Request().Header.Peek("k1")))
2021 })
2022
2023 go start()
2024
2025 C().SetDial(dial)
2026 resp, err := Get("http://example.com")
2027
2028 require.NoError(t, err)
2029 require.Equal(t, fiber.StatusOK, resp.StatusCode())
2030 require.Empty(t, resp.String())
2031
2032 r := New().SetDial(dial).SetHeader("k1", "v1")
2033 clean := Replace(r)
2034 resp, err = Get("http://example.com")
2035 require.NoError(t, err)
2036 require.Equal(t, fiber.StatusOK, resp.StatusCode())
2037 require.Equal(t, "v1", resp.String())
2038
2039 clean()
2040
2041 C().SetDial(dial)
2042 resp, err = Get("http://example.com")
2043
2044 require.NoError(t, err)
2045 require.Equal(t, fiber.StatusOK, resp.StatusCode())
2046 require.Empty(t, resp.String())
2047
2048 C().SetDial(nil)
2049}
2050
2051func Test_Replace_ConcurrentAccess(t *testing.T) {
2052 original := C()

Callers

nothing calls this directly

Calls 12

createHelperServerFunction · 0.85
GetFunction · 0.85
ReplaceFunction · 0.85
CFunction · 0.70
NewFunction · 0.70
GetMethod · 0.65
SendStringMethod · 0.65
RequestMethod · 0.65
SetDialMethod · 0.65
StringMethod · 0.65
StatusCodeMethod · 0.45
SetHeaderMethod · 0.45

Tested by

no test coverage detected