aboutsummaryrefslogtreecommitdiffstats
path: root/internal/bolttest/env.go
diff options
context:
space:
mode:
authorEugene Triguba <eugenetriguba@gmail.com>2024-03-09 12:07:30 -0500
committerEugene Triguba <eugenetriguba@gmail.com>2024-03-09 12:07:30 -0500
commit18cbade269362a3fed5763e2b1b39be33ba56aaf (patch)
treed31df309169381b83f9cad67da15f38d0b3cccc6 /internal/bolttest/env.go
parentAdd mysql docker compose file and use matrix in workflow (diff)
downloadcli-18cbade269362a3fed5763e2b1b39be33ba56aaf.zip
Fix tests to work without Dockerfile.test
Diffstat (limited to 'internal/bolttest/env.go')
-rw-r--r--internal/bolttest/env.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/internal/bolttest/env.go b/internal/bolttest/env.go
new file mode 100644
index 0000000..8f0ad63
--- /dev/null
+++ b/internal/bolttest/env.go
@@ -0,0 +1,19 @@
+package bolttest
+
+import (
+ "os"
+ "testing"
+
+ "github.com/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)
+ }
+}