MCPcopy
hub / github.com/moby/moby / mockJSONResponse

Function mockJSONResponse

client/client_mock_test.go:140–151  ·  view source on GitHub ↗
(statusCode int, headers http.Header, resp T)

Source from the content-addressed store, hash-verified

138}
139
140func 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.
154func mockPingResponse(statusCode int, ping PingResult) func(req *http.Request) (*http.Response, error) {

Callers 15

TestConfigUpdateFunction · 0.85
TestImageInspectFunction · 0.85
TestImageListFunction · 0.85
TestCheckpointListFunction · 0.85
TestServiceCreateFunction · 0.85
TestTaskListFunction · 0.85
TestExecCreateFunction · 0.85
TestExecStartConsoleSizeFunction · 0.85
TestExecInspectFunction · 0.85

Calls 4

mockResponseFunction · 0.85
SetMethod · 0.65
MarshalMethod · 0.45
CloneMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…