Skip to content

Commit 0c1017e

Browse files
authored
Make test env restoration only when needed (#118)
1 parent e5d48d2 commit 0c1017e

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

test/e2e/kubernetes_test.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@ import (
2424
)
2525

2626
func TestMain(m *testing.M) {
27+
runner := m.Run
2728
if isQASelected() {
28-
setQACredentialsEnvVars()
29-
setQAProject()
29+
runner = func() int {
30+
setQACredentialsEnvVars()
31+
defer restoreEnvVars()
32+
return m.Run()
33+
}
3034
}
31-
exitVal := m.Run()
32-
restoreEnvVars()
33-
os.Exit(exitVal)
35+
os.Exit(runner())
3436
}
3537

3638
func TestEnv(t *testing.T) {
@@ -90,7 +92,3 @@ func restoreEnv(envvar string) {
9092
func savedEnvVar(envvar string) string {
9193
return fmt.Sprintf("%s_SAVED", envvar)
9294
}
93-
94-
func setQAProject() {
95-
96-
}

0 commit comments

Comments
 (0)