(t *testing.T, handler fiber.Handler, wrapAgent func(agent *Request), excepted string, count ...int)
| 88 | } |
| 89 | |
| 90 | func testRequest(t *testing.T, handler fiber.Handler, wrapAgent func(agent *Request), excepted string, count ...int) { |
| 91 | t.Helper() |
| 92 | |
| 93 | app, ln, start := createHelperServer(t) |
| 94 | app.Get("/", handler) |
| 95 | go start() |
| 96 | |
| 97 | c := 1 |
| 98 | if len(count) > 0 { |
| 99 | c = count[0] |
| 100 | } |
| 101 | |
| 102 | client := New().SetDial(ln) |
| 103 | |
| 104 | for i := 0; i < c; i++ { |
| 105 | req := AcquireRequest().SetClient(client) |
| 106 | wrapAgent(req) |
| 107 | |
| 108 | resp, err := req.Get("http://example.com") |
| 109 | |
| 110 | require.NoError(t, err) |
| 111 | require.Equal(t, fiber.StatusOK, resp.StatusCode()) |
| 112 | require.Equal(t, excepted, resp.String()) |
| 113 | resp.Close() |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | func testRequestFail(t *testing.T, handler fiber.Handler, wrapAgent func(agent *Request), excepted error, count ...int) { |
| 118 | t.Helper() |
no test coverage detected