(statusCode int, headers http.Header, resp T)
| 138 | } |
| 139 | |
| 140 | func mockJSONResponse[T any](statusCode int, headers http.Header, resp T) func(req *http.Request) (*http.Response, error) { |
| 141 | respBody, err := json.Marshal(&resp) |
| 142 | if err != nil { |
| 143 | panic(err) |
| 144 | } |
| 145 | hdr := make(http.Header) |
| 146 | if headers != nil { |
| 147 | hdr = headers.Clone() |
| 148 | } |
| 149 | hdr.Set("Content-Type", "application/json") |
| 150 | return mockResponse(statusCode, hdr, string(respBody)) |
| 151 | } |
| 152 | |
| 153 | // mockPingResponse mocks the headers set for a "/_ping" response. |
| 154 | func mockPingResponse(statusCode int, ping PingResult) func(req *http.Request) (*http.Response, error) { |
no test coverage detected
searching dependent graphs…