From ad01eda95dd8a1c2efd9d5415e5f8b7869eadfe8 Mon Sep 17 00:00:00 2001 From: Sergey Makarov Date: Mon, 13 Nov 2023 11:42:38 +0100 Subject: [PATCH 1/3] [ISSUE-45] Fix bug with http.DefaultClient --- test.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test.go b/test.go index c70b4c8..d0be096 100644 --- a/test.go +++ b/test.go @@ -128,23 +128,30 @@ func (it *Test) clearFields() { } func (it *Test) initEmptyFields() { - it.httpClient = http.DefaultClient + if it.httpClient.Transport == nil || it.httpClient.Timeout == 0 { + it.httpClient = http.DefaultClient + } if it.AllureStep == nil { it.AllureStep = new(AllureStep) } + if it.Middleware == nil { it.Middleware = new(Middleware) } + if it.Expect == nil { it.Expect = new(Expect) } + if it.Request == nil { it.Request = new(Request) } + if it.Request.Repeat == nil { it.Request.Repeat = new(RequestRepeatPolitic) } + if it.Expect.JSONSchema == nil { it.Expect.JSONSchema = new(ExpectJSONSchema) } From 73de4e12bbef9350e1d69a51abbd6d3504de3584 Mon Sep 17 00:00:00 2001 From: Sergey Makarov Date: Mon, 13 Nov 2023 11:52:07 +0100 Subject: [PATCH 2/3] [ISSUE-45] remove useless --- test.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test.go b/test.go index d0be096..08bc29b 100644 --- a/test.go +++ b/test.go @@ -128,10 +128,6 @@ func (it *Test) clearFields() { } func (it *Test) initEmptyFields() { - if it.httpClient.Transport == nil || it.httpClient.Timeout == 0 { - it.httpClient = http.DefaultClient - } - if it.AllureStep == nil { it.AllureStep = new(AllureStep) } From 647aef96f995d2a4f808e2a9cd7bb8dd4d9d9a53 Mon Sep 17 00:00:00 2001 From: Sergey Makarov Date: Tue, 14 Nov 2023 16:21:10 +0100 Subject: [PATCH 3/3] [ISSUE-45] move log information about request --- roundtripper.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/roundtripper.go b/roundtripper.go index 06ca947..68f3b66 100644 --- a/roundtripper.go +++ b/roundtripper.go @@ -63,14 +63,16 @@ func (it *Test) doRequest(t T, baseReq *http.Request) (*http.Response, error) { return nil, err } + resp, err := it.httpClient.Do(req) + // Add information (method, host, curl) about request to Allure step + // should be after httpClient.Do, because in roundtripper request could be changed err = addInformationRequest(t, req) if err != nil { return nil, err } - resp, err := it.httpClient.Do(req) if err != nil { return nil, err