diff options
author | Valery Piashchynski <[email protected]> | 2020-02-28 00:43:52 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2020-02-28 00:43:52 +0300 |
commit | 94a2398f07e55819ffb9f8eb8d2141afe19f7575 (patch) | |
tree | 7294c22ce83c9d5293f9586c3ab141ed5b0702b3 | |
parent | 6ef4fb589c70038e6f6d1d165cf6feb575f9aadf (diff) |
Remove defer and move deferred statement just to end of Test_CORS_Pass
function
-rw-r--r-- | service/headers/service_test.go | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/service/headers/service_test.go b/service/headers/service_test.go index 2f29db5e..ce0f17cb 100644 --- a/service/headers/service_test.go +++ b/service/headers/service_test.go @@ -259,13 +259,6 @@ func TestCORS_Pass(t *testing.T) { r, err := http.DefaultClient.Do(req) assert.NoError(t, err) - defer func() { - err := r.Body.Close() - if err != nil { - t.Errorf("error during the body closing: error %v", err) - } - }() - assert.Equal(t, "true", r.Header.Get("Access-Control-Allow-Credentials")) assert.Equal(t, "*", r.Header.Get("Access-Control-Allow-Headers")) assert.Equal(t, "*", r.Header.Get("Access-Control-Allow-Origin")) @@ -275,4 +268,9 @@ func TestCORS_Pass(t *testing.T) { assert.NoError(t, err) assert.Equal(t, 200, r.StatusCode) + + err = r.Body.Close() + if err != nil { + t.Errorf("error during the body closing: error %v", err) + } } |