From 47d2353b41b4840755f01b4d308639fa604172a0 Mon Sep 17 00:00:00 2001 From: LarytheLord Date: Sun, 8 Mar 2026 18:32:35 +0530 Subject: [PATCH] test(cli): use t.Cleanup for resetEnv with t.Setenv Signed-off-by: LarytheLord --- pkg/cli/environment_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/cli/environment_test.go b/pkg/cli/environment_test.go index 9eed648ba..42df4a8a5 100644 --- a/pkg/cli/environment_test.go +++ b/pkg/cli/environment_test.go @@ -123,7 +123,8 @@ func TestEnvSettings(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - defer resetEnv()() + cleanup := resetEnv() + t.Cleanup(cleanup) for k, v := range tt.envvars { t.Setenv(k, v) @@ -244,7 +245,8 @@ func TestEnvOrBool(t *testing.T) { } func TestUserAgentHeaderInK8sRESTClientConfig(t *testing.T) { - defer resetEnv()() + cleanup := resetEnv() + t.Cleanup(cleanup) kubeconfigPath := filepath.Join(t.TempDir(), "config") kubeconfig := `apiVersion: v1