From df2401cb4adbb7529dfb45327699910c4f47e4ee Mon Sep 17 00:00:00 2001 From: Serhiy Mytrovtsiy Date: Thu, 4 Mar 2021 13:48:42 +0100 Subject: [PATCH] change how Request func works (does not throw error if not 200) --- request.go | 4 ---- request_test.go | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/request.go b/request.go index ff7ad6f..c7e3268 100644 --- a/request.go +++ b/request.go @@ -48,10 +48,6 @@ func Request(ctx context.Context, params RequestOpts) ([]byte, int, error) { return nil, 0, err } - if resp.StatusCode >= 400 { - return nil, resp.StatusCode, errors.New(string(body)) - } - return body, resp.StatusCode, nil } diff --git a/request_test.go b/request_test.go index 0edad83..b805eef 100644 --- a/request_test.go +++ b/request_test.go @@ -71,8 +71,8 @@ func TestRequest(t *testing.T) { URL: ts.URL, InjectBearer: true, }) - require.Error(t, err) - require.Nil(t, resp) + require.NoError(t, err) + require.NotNil(t, resp) require.Equal(t, http.StatusBadRequest, code) })