From f8f88ea0bd271c2fea63cf476b19edd8caead25d Mon Sep 17 00:00:00 2001 From: Jamie Magee Date: Wed, 11 Feb 2026 08:50:05 -0800 Subject: [PATCH] Replace client.Get with http.NewRequestWithContext in tests client.Get doesn't take a context, so the noctx linter flags it. Switch the three call sites in proxy_test.go to build an explicit request with context.Background() and use client.Do instead. --- proxy_test.go | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/proxy_test.go b/proxy_test.go index ce0c049..57e4ff8 100644 --- a/proxy_test.go +++ b/proxy_test.go @@ -37,7 +37,12 @@ func TestProxyHTTPRequest(t *testing.T) { url, httpSrv := testHTTPServer(t) defer httpSrv.Close() - rsp, err := client.Get(url) + req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, url, nil) + if err != nil { + t.Errorf("initializing new request: %v", err) + } + + rsp, err := client.Do(req) if err != nil { t.Errorf("making proxied request: %v", err) } @@ -63,7 +68,13 @@ func TestIPRestrictions(t *testing.T) { for _, url := range httpTestCases { t.Run(url, func(t *testing.T) { - rsp, err := client.Get(url) + req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, url, nil) + if err != nil { + t.Errorf("initializing new request: %v", err) + return + } + + rsp, err := client.Do(req) if err != nil { t.Errorf("making proxied request: %v", err) return @@ -86,7 +97,13 @@ func TestIPRestrictions(t *testing.T) { // the connection from being established while goproxy tries to setup TLS for _, url := range httpsTestCases { t.Run(url, func(t *testing.T) { - _, err := client.Get(url) //nolint:bodyclose // error expected, no body to close + req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, url, nil) + if err != nil { + t.Errorf("initializing new request: %v", err) + return + } + + _, err = client.Do(req) //nolint:bodyclose // error expected, no body to close assert.Error(t, err) }) }