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

Function testClient

client/helper_test.go:141–164  ·  view source on GitHub ↗
(t *testing.T, handler fiber.Handler, wrapAgent func(agent *Client), excepted string, count ...int)

Source from the content-addressed store, hash-verified

139}
140
141func testClient(t *testing.T, handler fiber.Handler, wrapAgent func(agent *Client), excepted string, count ...int) { //nolint:unparam // maybe needed
142 t.Helper()
143
144 app, ln, start := createHelperServer(t)
145 app.Get("/", handler)
146 go start()
147
148 c := 1
149 if len(count) > 0 {
150 c = count[0]
151 }
152
153 for i := 0; i < c; i++ {
154 client := New().SetDial(ln)
155 wrapAgent(client)
156
157 resp, err := client.Get("http://example.com")
158
159 require.NoError(t, err)
160 require.Equal(t, fiber.StatusOK, resp.StatusCode())
161 require.Equal(t, excepted, resp.String())
162 resp.Close()
163 }
164}

Calls 7

createHelperServerFunction · 0.85
NewFunction · 0.70
GetMethod · 0.65
SetDialMethod · 0.65
StringMethod · 0.65
CloseMethod · 0.65
StatusCodeMethod · 0.45

Tested by

no test coverage detected