From c5d9baaeb68d37e48178f9d3ba2d5b71c740f2a9 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Wed, 17 May 2023 13:01:26 +0300 Subject: [PATCH] pkg/proc,pkg/terminal: close response body in tests (#3372) --- pkg/proc/proc_test.go | 10 ++++++++-- pkg/terminal/command_test.go | 5 ++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/pkg/proc/proc_test.go b/pkg/proc/proc_test.go index b6852d3d9f..066c206520 100644 --- a/pkg/proc/proc_test.go +++ b/pkg/proc/proc_test.go @@ -741,7 +741,10 @@ func TestNextNetHTTP(t *testing.T) { } time.Sleep(50 * time.Millisecond) } - http.Get("http://127.0.0.1:9191") + resp, err := http.Get("http://127.0.0.1:9191") + if err == nil { + resp.Body.Close() + } }() if err := grp.Continue(); err != nil { t.Fatal(err) @@ -2913,7 +2916,10 @@ func TestAttachDetach(t *testing.T) { assertNoError(err, t, "Attach") go func() { time.Sleep(1 * time.Second) - http.Get("http://127.0.0.1:9191") + resp, err := http.Get("http://127.0.0.1:9191") + if err == nil { + resp.Body.Close() + } }() assertNoError(p.Continue(), t, "Continue") diff --git a/pkg/terminal/command_test.go b/pkg/terminal/command_test.go index 4a9177b460..36ac44e84c 100644 --- a/pkg/terminal/command_test.go +++ b/pkg/terminal/command_test.go @@ -693,7 +693,10 @@ func TestIssue827(t *testing.T) { withTestTerminal("notify-v2", t, func(term *FakeTerminal) { go func() { time.Sleep(1 * time.Second) - http.Get("http://127.0.0.1:8888/test") + resp, err := http.Get("http://127.0.0.1:8888/test") + if err == nil { + resp.Body.Close() + } time.Sleep(1 * time.Second) term.client.Halt() }()