diff options
Diffstat (limited to 'browserenv_unix_test.go')
-rw-r--r-- | browserenv_unix_test.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/browserenv_unix_test.go b/browserenv_unix_test.go new file mode 100644 index 0000000..bcc7c2d --- /dev/null +++ b/browserenv_unix_test.go @@ -0,0 +1,29 @@ +// +build !windows + +package browserenv + +import ( + "fmt" + "os" + "reflect" + "testing" +) + +func TestBrowserCommand(t *testing.T) { + envValue := "open -a Firefox" + url := "https://duckduckgo.com" + + cmd := browserCommand(envValue, url) + + shell := os.Getenv("SHELL") + if shell == "" { + shell = "/bin/sh" + } + + browserCommand := fmt.Sprintf("%s '%s'", envValue, url) + + wantArgs := []string{shell, "-c", browserCommand} + if !reflect.DeepEqual(cmd.Args, wantArgs) { + t.Errorf("got args '%#v' want '%#v'", cmd.Args, wantArgs) + } +} |