MCPcopy
hub / github.com/moby/moby / WithBaseMockClient

Function WithBaseMockClient

client/client_mock_test.go:128–132  ·  view source on GitHub ↗

WithBaseMockClient is a test helper that allows you to inject a mock client for testing. It is identical to [WithMockClient], but does not mock the "/_ping" endpoint, and doesn't set the default headers.

(doer func(*http.Request) (*http.Response, error))

Source from the content-addressed store, hash-verified

126// for testing. It is identical to [WithMockClient], but does not mock the "/_ping"
127// endpoint, and doesn't set the default headers.
128func WithBaseMockClient(doer func(*http.Request) (*http.Response, error)) Opt {
129 return WithHTTPClient(&http.Client{
130 Transport: ensureBody(doer),
131 })
132}
133
134func errorMock(statusCode int, message string) func(req *http.Request) (*http.Response, error) {
135 return mockJSONResponse(statusCode, nil, common.ErrorResponse{

Callers 15

TestNegotiateAPIVersionFunction · 0.85
TestWithUserAgentFunction · 0.85
TestWithHTTPHeadersFunction · 0.85
TestWithResponseHookFunction · 0.85
TestResponseErrorsFunction · 0.85
TestInfiniteErrorFunction · 0.85
TestPingFailFunction · 0.85

Calls 2

WithHTTPClientFunction · 0.85
ensureBodyFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…