Skip to content

Commit

Permalink
Defer unsetting test env vars properly
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed Dec 11, 2023
1 parent 138b0ab commit c96f1a6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions completions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3580,10 +3580,14 @@ func TestGetEnvConfig(t *testing.T) {
// Could make env handling cleaner with t.Setenv with Go >= 1.17
func() {
err := os.Setenv(tc.cmdVar, tc.cmdVal)
defer assertNoErr(t, os.Unsetenv(tc.cmdVar))
defer func() {
assertNoErr(t, os.Unsetenv(tc.cmdVar))
}()
assertNoErr(t, err)
err = os.Setenv(tc.globalVar, tc.globalVal)
defer assertNoErr(t, os.Unsetenv(tc.globalVar))
defer func() {
assertNoErr(t, os.Unsetenv(tc.globalVar))
}()
assertNoErr(t, err)
cmd := &Command{Use: tc.use}
got := getEnvConfig(cmd, tc.suffix)
Expand Down

0 comments on commit c96f1a6

Please sign in to comment.