Skip to content

Commit 0e81352

Browse files
committed
testing facilitation
1 parent 7bb6207 commit 0e81352

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

httpclient/client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ type ClientConfig struct {
9797

9898
// RetryEligiableRequests when false bypasses any retry logic for a simpler request flow.
9999
RetryEligiableRequests bool `json:"retry_eligiable_requests"`
100+
101+
HTTPExecutor HTTPExecutor
100102
}
101103

102104
// BuildClient creates a new HTTP client with the provided configuration.
@@ -120,9 +122,7 @@ func (c *ClientConfig) Build() (*Client, error) {
120122

121123
c.Sugar.Debug("configuration valid")
122124

123-
httpClient := &prodClient{
124-
&http.Client{},
125-
}
125+
httpClient := c.HTTPExecutor
126126

127127
cookieJar, err := cookiejar.New(nil)
128128
if err != nil {

httpclient/http.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,11 @@ func (c *prodClient) Cookies(url *url.URL) []*http.Cookie {
2929
func (c *prodClient) SetRedirectPolicy(policy *func(req *http.Request, via []*http.Request) error) {
3030
c.CheckRedirect = *policy
3131
}
32+
33+
type testClient struct {
34+
}
35+
36+
func (m *testClient) Do(req *http.Request) (*http.Response, error) {
37+
// do some stuff which makes a response you like
38+
return nil, nil
39+
}

0 commit comments

Comments
 (0)