From 16f62050044d8eaca1ee794ab1903a719895662f Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Mon, 13 Jan 2020 10:25:31 -0500 Subject: [PATCH] fix(test): Make resetEnv() properly reset settings Because the 'settings' variable is a pointer, it cannot be used to store the original envSettings and then restore them. Instead, this commit creates an entirely new envSettings, after having set the environment variables, which may affect it. Signed-off-by: Marc Khouzam --- cmd/helm/helm_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/helm/helm_test.go b/cmd/helm/helm_test.go index a08720e7a..b7156daf3 100644 --- a/cmd/helm/helm_test.go +++ b/cmd/helm/helm_test.go @@ -31,6 +31,7 @@ import ( "helm.sh/helm/v3/internal/test" "helm.sh/helm/v3/pkg/action" "helm.sh/helm/v3/pkg/chartutil" + "helm.sh/helm/v3/pkg/cli" kubefake "helm.sh/helm/v3/pkg/kube/fake" "helm.sh/helm/v3/pkg/release" "helm.sh/helm/v3/pkg/storage" @@ -136,14 +137,14 @@ func executeActionCommand(cmd string) (*cobra.Command, string, error) { } func resetEnv() func() { - origSettings, origEnv := settings, os.Environ() + origEnv := os.Environ() return func() { os.Clearenv() - settings = origSettings for _, pair := range origEnv { kv := strings.SplitN(pair, "=", 2) os.Setenv(kv[0], kv[1]) } + settings = cli.New() } }