mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-10 20:42:26 +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
53cccbe4f9
commit
fc643d2e40
@ -413,10 +413,8 @@ profiles:
|
|||||||
|
|
||||||
// Insulate this test from picking up in-cluster config when run inside a pod
|
// Insulate this test from picking up in-cluster config when run inside a pod
|
||||||
// We can't assume we have permissions to write to /var/run/secrets/... from a unit test to mock in-cluster config for testing
|
// We can't assume we have permissions to write to /var/run/secrets/... from a unit test to mock in-cluster config for testing
|
||||||
originalHost := os.Getenv("KUBERNETES_SERVICE_HOST")
|
if len(os.Getenv("KUBERNETES_SERVICE_HOST")) > 0 {
|
||||||
if len(originalHost) > 0 {
|
t.Setenv("KUBERNETES_SERVICE_HOST", "")
|
||||||
os.Setenv("KUBERNETES_SERVICE_HOST", "")
|
|
||||||
defer os.Setenv("KUBERNETES_SERVICE_HOST", originalHost)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultPodInitialBackoffSeconds := int64(1)
|
defaultPodInitialBackoffSeconds := int64(1)
|
||||||
|
Loading…
Reference in New Issue
Block a user