aboutsummaryrefslogtreecommitdiffstats
path: root/internal/bolttest/env.go
blob: 7295158df6fd76baa65c457d1f6c1c276dc2a8e6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package bolttest

import (
	"os"
	"testing"

	"git.sr.ht/~eugenetriguba/checkmate/assert"
)

func UnsetEnv(t *testing.T, key string) {
	originalVal, isSet := os.LookupEnv(key)
	if isSet {
		t.Cleanup(func() {
			err := os.Setenv(key, originalVal)
			assert.Nil(t, err)
		})
		os.Unsetenv(key)
	}
}