2026-03-03 19:21:24 +00:00
|
|
|
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) {
|
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 20:23:11 +00:00
|
|
|
if testing.Short() {
|
|
|
|
|
t.Skip("skipping live integration test (use without -short)")
|
2026-03-03 19:21:24 +00:00
|
|
|
}
|
|
|
|
|
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) {
|
refactor: reorganize into internal packages, fix critical panics and error handling
Move browser, config, player, and radio logic into internal/{config,radio,player,ui,version}.
Add cached API host resolution, context-aware HTTP client, and nil/length guards to eliminate
RandomIP, nslookup, reverseLookup, and GetStations panics. Replace subExecute with clean
legacyPlayer using Run-only execution. Fix inverted -short test guards, unformatted config
error messages, and "Erorr" typo. Remove obsolete vendor/GOPATH logic from build scripts.
Update callers in stations.go and radiomenu.go to new paths; retain shims for transition.
2026-06-05 20:10:54 +00:00
|
|
|
if testing.Short() {
|
|
|
|
|
t.Skip("skipping live integration test (use without -short)")
|
2026-03-03 19:21:24 +00:00
|
|
|
}
|
|
|
|
|
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")
|
|
|
|
|
}
|