gostations/stations_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

70 lines
1.5 KiB
Go

package main
import (
"bytes"
"os"
"testing"
)
func TestShowVersion_Unit(t *testing.T) {
t.Parallel()
t.Log("✓ Fast showVersion unit test")
tests := []struct {
name string
version string
expected string
}{
{"default version", "1.0.0", "1.0.0\n"},
{"empty version", "", "\n"},
{"dev version", "dev", "dev\n"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
originalVersion := version
version = tt.version
defer func() { version = originalVersion }()
// Safe stdout capture using pipe (no os.Stdout reassignment)
origStdout := os.Stdout
r, w, _ := os.Pipe()
os.Stdout = w
showVersion()
w.Close()
os.Stdout = origStdout
var buf bytes.Buffer
_, _ = buf.ReadFrom(r)
got := buf.String()
if got != tt.expected {
t.Errorf("showVersion() = %q, want %q", got, tt.expected)
}
})
}
}
func TestPrecheck_Unit(t *testing.T) {
t.Parallel()
t.Log("✓ Fast precheck unit test")
// Simple smoke test — calls the real precheck() in the common "player installed" path
// (no mocking of globals — that's not allowed in Go)
precheck()
t.Log("✓ precheck ran without panic (happy path)")
}
func TestPrecheck_Live(t *testing.T) {
if testing.Short() {
t.Skip("skipping live integration test (use without -short)")
}
t.Log("🧪 Running live precheck integration test...")
// Real precheck with whatever player is configured on this system
precheck()
t.Log("✓ Live precheck passed (no early exit)")
}