From e1da8faaf64b7ec6dbb59d8614942740fffbec61 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Tue, 25 Apr 2023 14:10:45 +0300 Subject: [PATCH] test: use ReplaceAll, remove unnecessary else --- http_test.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/http_test.go b/http_test.go index 42feb56967..e0256b46f4 100644 --- a/http_test.go +++ b/http_test.go @@ -833,17 +833,15 @@ func TestUseHostHeader2(t *testing.T) { req.Header.SetHost("SomeHost") if err := client.DoTimeout(req, resp, 1*time.Second); err != nil { t.Fatalf("DoTimeout returned an error '%v'", err) - } else { - if resp.StatusCode() != http.StatusOK { - t.Fatalf("DoTimeout: %v", resp.body) - } + } + if resp.StatusCode() != http.StatusOK { + t.Fatalf("DoTimeout: %v", resp.body) } if err := client.Do(req, resp); err != nil { t.Fatalf("DoTimeout returned an error '%v'", err) - } else { - if resp.StatusCode() != http.StatusOK { - t.Fatalf("Do: %q", resp.body) - } + } + if resp.StatusCode() != http.StatusOK { + t.Fatalf("Do: %q", resp.body) } } @@ -2588,7 +2586,7 @@ func TestWriteMultipartForm(t *testing.T) { t.Parallel() var w bytes.Buffer - s := strings.Replace(`--foo + s := strings.ReplaceAll(`--foo Content-Disposition: form-data; name="key" value @@ -2598,7 +2596,7 @@ Content-Type: application/json {"foo": "bar"} --foo-- -`, "\n", "\r\n", -1) +`, "\n", "\r\n") mr := multipart.NewReader(strings.NewReader(s), "foo") form, err := mr.ReadForm(1024) if err != nil {