From 0205bc3018549180de5ff22904db5565e69e03a8 Mon Sep 17 00:00:00 2001 From: Sergei Makarov <33636772+siller174@users.noreply.github.com> Date: Fri, 17 May 2024 09:55:32 +0200 Subject: [PATCH] [ISSUE-73] fix error check in http do (#74) * [ISSUE-73] fix error check in http do * [issue-73] update allure --- go.mod | 4 ++-- go.sum | 8 ++++---- roundtripper.go | 8 ++++++++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index c62b16b..120d36d 100644 --- a/go.mod +++ b/go.mod @@ -5,8 +5,8 @@ go 1.21 require ( github.com/josephburnett/jd v1.7.1 github.com/ohler55/ojg v1.21.1 - github.com/ozontech/allure-go/pkg/allure v0.6.13-0.20240320124242-dd7f2ab15350 - github.com/ozontech/allure-go/pkg/framework v0.6.30-0.20240320124242-dd7f2ab15350 + github.com/ozontech/allure-go/pkg/allure v0.6.13 + github.com/ozontech/allure-go/pkg/framework v0.6.31 github.com/stretchr/testify v1.8.4 github.com/xeipuuv/gojsonschema v1.2.0 moul.io/http2curl/v2 v2.3.0 diff --git a/go.sum b/go.sum index d0c0bd5..c3da37e 100644 --- a/go.sum +++ b/go.sum @@ -27,10 +27,10 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWb github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/ohler55/ojg v1.21.1 h1:b2RLUaDcy9gvn46dmhTjezu/TDauoR0/kgKTqkwIxto= github.com/ohler55/ojg v1.21.1/go.mod h1:gQhDVpQLqrmnd2eqGAvJtn+NfKoYJbe/A4Sj3/Vro4o= -github.com/ozontech/allure-go/pkg/allure v0.6.13-0.20240320124242-dd7f2ab15350 h1:IBKoi5yMF3kINxJ5YWRCjitZm2n5jA6kq8qqZu1OmsA= -github.com/ozontech/allure-go/pkg/allure v0.6.13-0.20240320124242-dd7f2ab15350/go.mod h1:4oEG2yq+DGOzJS/ZjPc87C/mx3tAnlYpYonk77Ru/vQ= -github.com/ozontech/allure-go/pkg/framework v0.6.30-0.20240320124242-dd7f2ab15350 h1:QYE7DoTcAIKDd0BKe9epSK8j9bwOaQx0zS4zoGe7LlE= -github.com/ozontech/allure-go/pkg/framework v0.6.30-0.20240320124242-dd7f2ab15350/go.mod h1:ZNUnhean4TKmDwHPX2Jwr3y/o0WTeyuXB9aKKRcyHBg= +github.com/ozontech/allure-go/pkg/allure v0.6.13 h1:vkLSIvOEERHTxe+oq8DXDu/m+kLnVUkrXNN8xTKuKU4= +github.com/ozontech/allure-go/pkg/allure v0.6.13/go.mod h1:4oEG2yq+DGOzJS/ZjPc87C/mx3tAnlYpYonk77Ru/vQ= +github.com/ozontech/allure-go/pkg/framework v0.6.31 h1:u32AqB9/JkzcL5vSl8PSUmMZbsVTmoriDylI3FIYgX4= +github.com/ozontech/allure-go/pkg/framework v0.6.31/go.mod h1:wfqY4e4+w4BoRFDxHp7TNcdWfcCOWJV3BjrUqUughWY= github.com/pkg/diff v0.0.0-20200914180035-5b29258ca4f7/go.mod h1:zO8QMzTeZd5cpnIkz/Gn6iK0jDfGicM1nynOkkPIl28= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= diff --git a/roundtripper.go b/roundtripper.go index 33edd7d..5a75fd4 100644 --- a/roundtripper.go +++ b/roundtripper.go @@ -72,7 +72,15 @@ func (it *Test) doRequest(t T, baseReq *http.Request) (*http.Response, error) { } resp, httpErr := it.httpClient.Do(req) + + // http client has case wheh it return response and error in one time + // we have to check this case if resp == nil { + if httpErr != nil { + return nil, cuteErrors.NewCuteError("[HTTP] Could not do request", httpErr) + } + + // if response is nil, we can't get information about request and response return nil, cuteErrors.NewCuteError("[HTTP] Response is nil", httpErr) }