diff --git a/browser.go b/browser.go index d7969d7..dc6fca1 100644 --- a/browser.go +++ b/browser.go @@ -1,6 +1,6 @@ // Package browser provides helpers to open files, readers, and urls in a browser window. // -// The choice of which browser is started is entirely client dependant. +// The choice of which browser is started is entirely client dependent. package browser import ( diff --git a/browser_test.go b/browser_test.go new file mode 100644 index 0000000..a6e5ec9 --- /dev/null +++ b/browser_test.go @@ -0,0 +1,33 @@ +package browser + +import ( + "bytes" + "os" + "strings" + "testing" +) + +func TestRunCmd(t *testing.T) { + var stdout, stderr bytes.Buffer + Stdout = &stdout + Stderr = &stderr + defer func() { + Stdout = os.Stdout + Stderr = os.Stderr + }() + + err := runCmd("echo", "hello", "world") + if err != nil { + t.Fatalf("runCmd failed: %v", err) + } + if !strings.Contains(stdout.String(), "hello world") { + t.Errorf("stdout = %q, expected to contain %q", stdout.String(), "hello world") + } +} + +func TestRunCmdError(t *testing.T) { + err := runCmd("nonexistent-command-xyz-12345") + if err == nil { + t.Error("expected error for nonexistent command, got nil") + } +}