MCPcopy
hub / github.com/caddyserver/caddy / AssertPostResponseBody

Method AssertPostResponseBody

caddytest/caddytest.go:569–581  ·  view source on GitHub ↗

AssertPostResponseBody requests a URI with POST and asserts the response code and body.

(requestURI string, requestHeaders []string, requestBody *bytes.Buffer, expectedStatusCode int, expectedBody string)

Source from the content-addressed store, hash-verified

567
568// AssertPostResponseBody requests a URI with POST and asserts the response code and body.
569func (tc *Tester) AssertPostResponseBody(requestURI string, requestHeaders []string, requestBody *bytes.Buffer, expectedStatusCode int, expectedBody string) (*http.Response, string) {
570 tc.t.Helper()
571
572 req, err := http.NewRequest("POST", requestURI, requestBody)
573 if err != nil {
574 tc.t.Errorf("failed to create request %s", err)
575 return nil, ""
576 }
577
578 applyHeaders(tc.t, req, requestHeaders)
579
580 return tc.AssertResponse(req, expectedStatusCode, expectedBody)
581}
582
583// AssertPutResponseBody requests a URI with PUT and asserts the response code and body.
584func (tc *Tester) AssertPutResponseBody(requestURI string, requestHeaders []string, requestBody *bytes.Buffer, expectedStatusCode int, expectedBody string) (*http.Response, string) {

Callers 5

TestCheckIDFunction · 0.95
TestMapFunction · 0.95
TestMapAsJSONFunction · 0.95
TestRespondWithJSONFunction · 0.95

Calls 2

AssertResponseMethod · 0.95
applyHeadersFunction · 0.85

Tested by 5

TestCheckIDFunction · 0.76
TestMapFunction · 0.76
TestMapAsJSONFunction · 0.76
TestRespondWithJSONFunction · 0.76