diff --git a/testing/proxytest/proxytest_test.go b/testing/proxytest/proxytest_test.go index c768e875083..f367ced2b62 100644 --- a/testing/proxytest/proxytest_test.go +++ b/testing/proxytest/proxytest_test.go @@ -233,8 +233,10 @@ func TestProxy(t *testing.T) { func TestHTTPSProxy(t *testing.T) { targetHost := "not-a-server.co" proxy, client, target := prepareMTLSProxyAndTargetServer(t, targetHost) - defer proxy.Close() - defer target.Close() + t.Cleanup(func() { + proxy.Close() + target.Close() + }) tcs := []struct { name string