(t *testing.T, ts *httptest.Server, method, path string, body io.Reader)
| 1981 | } |
| 1982 | |
| 1983 | func testRequest(t *testing.T, ts *httptest.Server, method, path string, body io.Reader) (*http.Response, string) { |
| 1984 | req, err := http.NewRequest(method, ts.URL+path, body) |
| 1985 | if err != nil { |
| 1986 | t.Fatal(err) |
| 1987 | return nil, "" |
| 1988 | } |
| 1989 | |
| 1990 | resp, err := http.DefaultClient.Do(req) |
| 1991 | if err != nil { |
| 1992 | t.Fatal(err) |
| 1993 | return nil, "" |
| 1994 | } |
| 1995 | |
| 1996 | respBody, err := io.ReadAll(resp.Body) |
| 1997 | if err != nil { |
| 1998 | t.Fatal(err) |
| 1999 | return nil, "" |
| 2000 | } |
| 2001 | defer resp.Body.Close() |
| 2002 | |
| 2003 | return resp, string(respBody) |
| 2004 | } |
| 2005 | |
| 2006 | func testHandler(t *testing.T, h http.Handler, method, path string, body io.Reader) (*http.Response, string) { |
| 2007 | r, _ := http.NewRequest(method, path, body) |
no test coverage detected