Skip to content

Commit

Permalink
testing facilitation
Browse files Browse the repository at this point in the history
  • Loading branch information
thejoeker12 committed Jul 24, 2024
1 parent 7bb6207 commit 0e81352
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 3 additions & 3 deletions httpclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ type ClientConfig struct {

// RetryEligiableRequests when false bypasses any retry logic for a simpler request flow.
RetryEligiableRequests bool `json:"retry_eligiable_requests"`

HTTPExecutor HTTPExecutor
}

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

c.Sugar.Debug("configuration valid")

httpClient := &prodClient{
&http.Client{},
}
httpClient := c.HTTPExecutor

cookieJar, err := cookiejar.New(nil)
if err != nil {
Expand Down
8 changes: 8 additions & 0 deletions httpclient/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,11 @@ func (c *prodClient) Cookies(url *url.URL) []*http.Cookie {
func (c *prodClient) SetRedirectPolicy(policy *func(req *http.Request, via []*http.Request) error) {
c.CheckRedirect = *policy
}

type testClient struct {
}

func (m *testClient) Do(req *http.Request) (*http.Response, error) {
// do some stuff which makes a response you like
return nil, nil
}

0 comments on commit 0e81352

Please sign in to comment.