From befe13b4c49b97b1179b9b54dd2115427b8e6841 Mon Sep 17 00:00:00 2001 From: "Egor.Gorlin" Date: Fri, 10 Jun 2022 13:58:44 +0300 Subject: [PATCH 1/2] Replace explicit http.Client usage to narrow interface. --- events/configuration.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/events/configuration.go b/events/configuration.go index ddc79d3..0b03dfc 100644 --- a/events/configuration.go +++ b/events/configuration.go @@ -30,6 +30,10 @@ type BasicAuth struct { APISecret string `json:"apiSecret,omitempty"` } +type RequestDoer interface { + Do(req *http.Request) (*http.Response, error) +} + // Configuration stores the configuration of the API client type Configuration struct { BasePath string `json:"basePath,omitempty"` @@ -37,7 +41,7 @@ type Configuration struct { Scheme string `json:"scheme,omitempty"` DefaultHeader map[string]string `json:"defaultHeader,omitempty"` UserAgent string `json:"userAgent,omitempty"` - HTTPClient *http.Client + HTTPClient RequestDoer } // NewConfiguration returns a new Configuration object From 98aca69e7620c94095a283d53b98d5d263562aff Mon Sep 17 00:00:00 2001 From: "Egor.Gorlin" Date: Fri, 10 Jun 2022 13:59:27 +0300 Subject: [PATCH 2/2] Fix api events test. Update CustomAttributes type to correct one. --- events/api_events_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/events/api_events_test.go b/events/api_events_test.go index eabbb03..a7a13ed 100644 --- a/events/api_events_test.go +++ b/events/api_events_test.go @@ -62,7 +62,7 @@ func TestFullBatch(t *testing.T) { customEvent := NewCustomEvent() customEvent.Data.EventName = "My Custom Event Name" customEvent.Data.CustomEventType = OtherCustomEventType - customEvent.Data.CustomAttributes = make(map[string]string) + customEvent.Data.CustomAttributes = make(map[string]interface{}) customEvent.Data.CustomAttributes["foo"] = "bar" screenEvent := NewScreenViewEvent()