From 9f293f238706279905a4159ec647e32eb814ca41 Mon Sep 17 00:00:00 2001 From: John Schnake Date: Thu, 1 Jul 2021 21:27:23 -0400 Subject: [PATCH] Fix a unit test by avoiding local kubeconfig The test naturally picks up on the local kubeconfig so we need to intentionally set it to a "bad" value here. Fixes #1345 Signed-off-by: John Schnake --- cmd/sonobuoy/app/images_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/sonobuoy/app/images_test.go b/cmd/sonobuoy/app/images_test.go index e3b382868..745b6e526 100644 --- a/cmd/sonobuoy/app/images_test.go +++ b/cmd/sonobuoy/app/images_test.go @@ -95,6 +95,9 @@ func TestGetClusterVersion(t *testing.T) { }, } for _, tc := range testCases { + // Dont let actual local env impact these tests. + defer os.Setenv("KUBECONFIG", os.Getenv("KUBECONFIG")) + os.Setenv("KUBECONFIG", "/foo/bar/not/a/kubeconfig") t.Run(tc.desc, func(t *testing.T) { output, err := getClusterVersion(tc.input, Kubeconfig{}) switch {