mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-03 08:04:45 +00:00
Replace os.Setenv with testing.T.Setenv in tests
T.Setenv ensures that the environment is returned to its prior state when the test ends. It also panics when called from a parallel test to prevent racy test interdependencies. Kubernetes-commit: 89467ad3e9b051515fa9632a7373d6ef01723256
This commit is contained in:
committed by
Kubernetes Publisher
parent
383ccb06d0
commit
18ffb5c67f
@@ -897,12 +897,9 @@ func TestLoadingGetLoadingPrecedence(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
kubeconfig := os.Getenv("KUBECONFIG")
|
||||
defer os.Setenv("KUBECONFIG", kubeconfig)
|
||||
|
||||
for name, test := range testCases {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
os.Setenv("KUBECONFIG", test.env)
|
||||
t.Setenv("KUBECONFIG", test.env)
|
||||
rules := test.rules
|
||||
if rules == nil {
|
||||
rules = NewDefaultClientConfigLoadingRules()
|
||||
|
Reference in New Issue
Block a user