NewMockHTTPClient creates a new mock HTTP client with a default success response
()
| 28 | |
| 29 | // NewMockHTTPClient creates a new mock HTTP client with a default success response |
| 30 | func 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 |
| 43 | func (m *MockHTTPClient) SetResponse(resp *http.Response) { |
no outgoing calls
no test coverage detected