(t *testing.T, ts *httptest.Server, method, path string, body io.Reader)
| 80 | } |
| 81 | |
| 82 | func testRequest(t *testing.T, ts *httptest.Server, method, path string, body io.Reader) (*http.Response, string) { |
| 83 | req, err := http.NewRequest(method, ts.URL+path, body) |
| 84 | if err != nil { |
| 85 | t.Fatal(err) |
| 86 | return nil, "" |
| 87 | } |
| 88 | |
| 89 | resp, err := http.DefaultClient.Do(req) |
| 90 | if err != nil { |
| 91 | t.Fatal(err) |
| 92 | return nil, "" |
| 93 | } |
| 94 | |
| 95 | respBody, err := io.ReadAll(resp.Body) |
| 96 | if err != nil { |
| 97 | t.Fatal(err) |
| 98 | return nil, "" |
| 99 | } |
| 100 | defer resp.Body.Close() |
| 101 | |
| 102 | return resp, string(respBody) |
| 103 | } |
| 104 | |
| 105 | func testRequestNoRedirect(t *testing.T, ts *httptest.Server, method, path string, body io.Reader) (*http.Response, string) { |
| 106 | req, err := http.NewRequest(method, ts.URL+path, body) |
no test coverage detected