mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-19 05:45:56 +02:00
test: use T.Setenv to set env vars in tests (#189)
This commit replaces `os.Setenv` with `t.Setenv` in tests. The environment variable is automatically restored to its original value when the test and all its subtests complete. Reference: https://pkg.go.dev/testing#T.Setenv Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
@@ -94,11 +94,9 @@ func TestGetTillerlessEnv(t *testing.T) {
|
||||
hc := &HelmContext{
|
||||
Tillerless: test.tillerless,
|
||||
}
|
||||
os.Setenv(kubeconfigEnv, test.kubeconfig)
|
||||
t.Setenv(kubeconfigEnv, test.kubeconfig)
|
||||
result := hc.getTillerlessEnv()
|
||||
require.Equalf(t, test.expected, result, "expected result %s, received result %s", test.expected, result)
|
||||
|
||||
}
|
||||
defer os.Unsetenv(kubeconfigEnv)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user