File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -135,18 +135,15 @@ func TestDetectPigz(t *testing.T) {
135135 t .Fatal (err )
136136 }
137137
138- oldPath := os .Getenv ("PATH" )
139- os .Setenv ("PATH" , tempPath )
140- defer os .Setenv ("PATH" , oldPath )
138+ t .Setenv ("PATH" , tempPath )
141139
142140 if pigzPath := detectPigz (); pigzPath == "" {
143141 t .Fatal ("failed to detect pigz path" )
144142 } else if pigzPath != fullPath {
145143 t .Fatalf ("wrong pigz found: %s != %s" , pigzPath , fullPath )
146144 }
147145
148- os .Setenv (disablePigzEnv , "1" )
149- defer os .Unsetenv (disablePigzEnv )
146+ t .Setenv (disablePigzEnv , "1" )
150147
151148 if pigzPath := detectPigz (); pigzPath != "" {
152149 t .Fatalf ("disable via %s doesn't work" , disablePigzEnv )
Original file line number Diff line number Diff line change @@ -18,7 +18,6 @@ package namespaces
1818
1919import (
2020 "context"
21- "os"
2221 "testing"
2322)
2423
@@ -47,9 +46,6 @@ func TestContext(t *testing.T) {
4746}
4847
4948func TestNamespaceFromEnv (t * testing.T ) {
50- oldenv := os .Getenv (NamespaceEnvVar )
51- defer os .Setenv (NamespaceEnvVar , oldenv ) // restore old env var
52-
5349 ctx := context .Background ()
5450 namespace , ok := Namespace (ctx )
5551 if ok {
@@ -61,7 +57,7 @@ func TestNamespaceFromEnv(t *testing.T) {
6157 }
6258
6359 expected := "test-namespace"
64- os .Setenv (NamespaceEnvVar , expected )
60+ t .Setenv (NamespaceEnvVar , expected )
6561 nctx := NamespaceFromEnv (ctx )
6662
6763 namespace , ok = Namespace (nctx )
Original file line number Diff line number Diff line change @@ -18,7 +18,6 @@ package shim
1818
1919import (
2020 "context"
21- "os"
2221 "runtime"
2322 "testing"
2423)
@@ -27,7 +26,7 @@ func TestRuntimeWithEmptyMaxEnvProcs(t *testing.T) {
2726 var oldGoMaxProcs = runtime .GOMAXPROCS (0 )
2827 defer runtime .GOMAXPROCS (oldGoMaxProcs )
2928
30- os .Setenv ("GOMAXPROCS" , "" )
29+ t .Setenv ("GOMAXPROCS" , "" )
3130 setRuntime ()
3231
3332 var currentGoMaxProcs = runtime .GOMAXPROCS (0 )
@@ -37,7 +36,7 @@ func TestRuntimeWithEmptyMaxEnvProcs(t *testing.T) {
3736}
3837
3938func TestRuntimeWithNonEmptyMaxEnvProcs (t * testing.T ) {
40- os .Setenv ("GOMAXPROCS" , "not_empty" )
39+ t .Setenv ("GOMAXPROCS" , "not_empty" )
4140 setRuntime ()
4241 var oldGoMaxProcs2 = runtime .GOMAXPROCS (0 )
4342 if oldGoMaxProcs2 != runtime .NumCPU () {
You can’t perform that action at this time.
0 commit comments