aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2020-12-20 19:12:00 +0100
committerTeddy Wing2020-12-20 19:12:00 +0100
commit8d4c2f66ce0998f39f0dda1986afd0cc641a7dc1 (patch)
tree68d90ce6ad181158f9300c764b615fa733a0302c
parent86bef4a173ad72af37747318dd6955f9d3050b3e (diff)
downloadbrowserenv-8d4c2f66ce0998f39f0dda1986afd0cc641a7dc1.tar.bz2
browserenv_unix_test: Unset `BROWSER` in tests that set it
The `BROWSER` environment variable value is carried over after each test, meaning if subsequent tests depend on it being undefined, they will fail. Unset the environment variable at the end of each test that sets it.
-rw-r--r--browserenv_unix_test.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/browserenv_unix_test.go b/browserenv_unix_test.go
index 971454e..069c322 100644
--- a/browserenv_unix_test.go
+++ b/browserenv_unix_test.go
@@ -9,6 +9,15 @@ import (
"testing"
)
+func unsetEnvBrowser(t *testing.T) {
+ t.Helper()
+
+ err := os.Unsetenv("BROWSER")
+ if err != nil {
+ t.Fatal(err)
+ }
+}
+
func TestBrowserCommand(t *testing.T) {
tests := []struct {
name string
@@ -76,6 +85,8 @@ func TestOpenURLStdout(t *testing.T) {
if got != url {
t.Errorf("got stdout value %q want %q", got, url)
}
+
+ unsetEnvBrowser(t)
}
func TestOpenURLStderr(t *testing.T) {
@@ -95,6 +106,8 @@ func TestOpenURLStderr(t *testing.T) {
if got != url {
t.Errorf("got stdout value %q want %q", got, url)
}
+
+ unsetEnvBrowser(t)
}
func TestOpenURLMultipleBrowserCommands(t *testing.T) {
@@ -115,4 +128,6 @@ func TestOpenURLMultipleBrowserCommands(t *testing.T) {
if got != url {
t.Errorf("got stdout value %q want %q", got, url)
}
+
+ unsetEnvBrowser(t)
}