MCPcopy
hub / github.com/moby/moby / WithMockClient

Function WithMockClient

client/client_mock_test.go:119–123  ·  view source on GitHub ↗

WithMockClient is a test helper that allows you to inject a mock client for testing. By default, it mocks the "/_ping" endpoint, so allow the client to perform API-version negotiation. Other endpoints are handled by "doer".

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

Source from the content-addressed store, hash-verified

117// testing. By default, it mocks the "/_ping" endpoint, so allow the client
118// to perform API-version negotiation. Other endpoints are handled by "doer".
119func WithMockClient(doer func(*http.Request) (*http.Response, error)) Opt {
120 return WithHTTPClient(&http.Client{
121 Transport: makeTestRoundTripper(doer),
122 })
123}
124
125// WithBaseMockClient is a test helper that allows you to inject a mock client
126// for testing. It is identical to [WithMockClient], but does not mock the "/_ping"

Callers 15

TestConfigUpdateErrorFunction · 0.85
TestConfigUpdateFunction · 0.85
TestNetworkConnectErrorFunction · 0.85
TestNetworkConnectFunction · 0.85
TestPluginPushErrorFunction · 0.85
TestPluginPushFunction · 0.85
TestImageInspectErrorFunction · 0.85
TestImageInspectFunction · 0.85

Calls 2

WithHTTPClientFunction · 0.85
makeTestRoundTripperFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…