aboutsummaryrefslogtreecommitdiffstats
path: root/browserenv_unix_test.go
blob: bcc7c2dd429ae69ddf37bc5cdabfa7f9bc99ffd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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)
	}
}