mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-08 03:33:56 +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.
This commit is contained in:
parent
c07c739f04
commit
ac5ce5cbce
@ -149,7 +149,7 @@ func TestToleratingMissingFiles(t *testing.T) {
|
|||||||
|
|
||||||
func TestWarningMissingFiles(t *testing.T) {
|
func TestWarningMissingFiles(t *testing.T) {
|
||||||
envVarValue := "bogus"
|
envVarValue := "bogus"
|
||||||
os.Setenv(RecommendedConfigPathEnvVar, envVarValue)
|
t.Setenv(RecommendedConfigPathEnvVar, envVarValue)
|
||||||
loadingRules := NewDefaultClientConfigLoadingRules()
|
loadingRules := NewDefaultClientConfigLoadingRules()
|
||||||
|
|
||||||
buffer := &bytes.Buffer{}
|
buffer := &bytes.Buffer{}
|
||||||
@ -174,7 +174,7 @@ func TestWarningMissingFiles(t *testing.T) {
|
|||||||
|
|
||||||
func TestNoWarningMissingFiles(t *testing.T) {
|
func TestNoWarningMissingFiles(t *testing.T) {
|
||||||
envVarValue := "bogus"
|
envVarValue := "bogus"
|
||||||
os.Setenv(RecommendedConfigPathEnvVar, envVarValue)
|
t.Setenv(RecommendedConfigPathEnvVar, envVarValue)
|
||||||
loadingRules := NewDefaultClientConfigLoadingRules()
|
loadingRules := NewDefaultClientConfigLoadingRules()
|
||||||
|
|
||||||
buffer := &bytes.Buffer{}
|
buffer := &bytes.Buffer{}
|
||||||
|
Loading…
Reference in New Issue
Block a user