MCPcopy Index your code
hub / github.com/docker/docker-agent / NewMockHTTPClient

Function NewMockHTTPClient

pkg/telemetry/telemetry_test.go:30–40  ·  view source on GitHub ↗

NewMockHTTPClient creates a new mock HTTP client with a default success response

()

Source from the content-addressed store, hash-verified

28
29// NewMockHTTPClient creates a new mock HTTP client with a default success response
30func NewMockHTTPClient() *MockHTTPClient {
31 mock := &MockHTTPClient{
32 response: &http.Response{
33 StatusCode: http.StatusOK,
34 Body: io.NopCloser(bytes.NewReader([]byte(`{"success": true}`))),
35 Header: make(http.Header),
36 },
37 }
38 mock.Client = &http.Client{Transport: mock}
39 return mock
40}
41
42// SetResponse allows updating the mock response for testing different scenarios
43func (m *MockHTTPClient) SetResponse(resp *http.Response) {

Callers 7

TestSessionTrackingFunction · 0.85
TestCommandTrackingFunction · 0.85
TestAllEventTypesFunction · 0.85
TestTelemetryTagsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected