gostations/commander_test.go
Greg Gauthier ec5db53b8e
Some checks failed
gobuild / build (push) Failing after 4s
feat(cli): default to bubbles TUI, add find/play subcmds + JSON favorites
- implement internal/ui with bubbles list + ★ fav markers, filter, enter stub
- add data/favorites (JSON roundtrip, Add/Remove, XDG), config tests
- wire subcommands: `find -j`, `play [url|search]`
- gate legacy wmenu behind --legacy; keep old flags for seeding
- fix inverted -short guards, format string, go.mod deps
- add unit tests for radio prune, player IsInstalled, ui keys, etc.
2026-06-05 21:23:11 +01:00

72 lines
1.5 KiB
Go

package main
import (
"runtime"
"testing"
)
func TestIsInstalled_Unit(t *testing.T) {
t.Parallel()
t.Log("✓ Fast isInstalled unit test")
tests := []struct {
name string
cmd string
want bool
}{
{"sh exists", "sh", true},
{"non-existent", "nonexistentcmd123456789", false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := isInstalled(tt.cmd)
if got != tt.want {
t.Errorf("isInstalled(%q) = %v, want %v", tt.cmd, got, tt.want)
}
})
}
}
func TestIsInstalled_Live(t *testing.T) {
if testing.Short() {
t.Skip("skipping live integration test (use without -short)")
}
t.Log("🧪 Running live isInstalled integration test...")
if runtime.GOOS == "windows" {
t.Skip("isInstalled uses /bin/sh (Unix-only)")
}
if !isInstalled("sh") {
t.Error("sh should be installed on this system")
}
t.Log("✓ Live isInstalled test passed")
}
func TestSubExecute_Unit(t *testing.T) {
t.Parallel()
t.Log("✓ Fast subExecute unit test")
_, err := subExecute("nonexistentcmd123456789")
if err == nil {
t.Error("expected error for non-existent command")
}
}
func TestSubExecute_Live(t *testing.T) {
if testing.Short() {
t.Skip("skipping live integration test (use without -short)")
}
t.Log("🧪 Running live subExecute integration test...")
output, err := subExecute("echo", "hello from live test")
if err != nil {
t.Fatalf("subExecute failed: %v", err)
}
if len(output) == 0 {
t.Error("expected output")
}
t.Log("✓ subExecute live test passed")
}