MCPcopy
hub / github.com/go-chi/chi / testRequest

Function testRequest

mux_test.go:1983–2004  ·  view source on GitHub ↗
(t *testing.T, ts *httptest.Server, method, path string, body io.Reader)

Source from the content-addressed store, hash-verified

1981}
1982
1983func 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
2006func testHandler(t *testing.T, h http.Handler, method, path string, body io.Reader) (*http.Response, string) {
2007 r, _ := http.NewRequest(method, path, body)

Callers 15

TestMuxBasicFunction · 0.70
TestMuxMountsFunction · 0.70
TestMuxPlainFunction · 0.70
TestMuxTrailingSlashFunction · 0.70
TestMuxNestedNotFoundFunction · 0.70
TestMethodNotAllowedFunction · 0.70
TestMuxWithFunction · 0.70
TestRouterFromMuxWithFunction · 0.70
TestMuxMiddlewareStackFunction · 0.70

Calls 1

CloseMethod · 0.80

Tested by

no test coverage detected