From b79a03aaf94639119b26b5c6fef101b812c67d29 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Wed, 15 Feb 2023 12:54:23 +0200 Subject: [PATCH] test: close response body (#1496) --- .github/workflows/lint.yml | 2 +- fasthttputil/inmemory_listener_test.go | 1 + header_test.go | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 7ea38d7ded..607432a1a5 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -18,4 +18,4 @@ jobs: uses: golangci/golangci-lint-action@v3 with: version: v1.51.1 - args: --enable=nolintlint --enable=gochecknoinits --verbose + args: --enable=nolintlint,gochecknoinits,bodyclose --verbose diff --git a/fasthttputil/inmemory_listener_test.go b/fasthttputil/inmemory_listener_test.go index e9d5125202..cbaa6dfad9 100644 --- a/fasthttputil/inmemory_listener_test.go +++ b/fasthttputil/inmemory_listener_test.go @@ -146,6 +146,7 @@ func testInmemoryListenerHTTPSingle(t *testing.T, client *http.Client, content s if err != nil { t.Fatalf("unexpected error: %v", err) } + defer func() { _ = res.Body.Close() }() b, err := io.ReadAll(res.Body) if err != nil { t.Fatalf("unexpected error: %v", err) diff --git a/header_test.go b/header_test.go index 0129f3f077..b23defafbf 100644 --- a/header_test.go +++ b/header_test.go @@ -71,6 +71,7 @@ func TestResponseHeaderMultiLineValue(t *testing.T) { if err != nil { t.Fatalf("parse response using net/http failed, %v", err) } + defer func() { _ = response.Body.Close() }() if !bytes.Equal(header.StatusMessage(), []byte("SuperOK")) { t.Errorf("parse status line with non-default value failed, got: '%q' want: 'SuperOK'", header.StatusMessage())