From 66b7f808f708164f148196922276d381445362b6 Mon Sep 17 00:00:00 2001 From: Greg Gauthier Date: Sat, 6 Jun 2026 08:12:56 +0100 Subject: [PATCH] fix(test): make TestPrecheck_Unit skip gracefully when player (mpv) is not installed (as in minimal CI runners); prevents os.Exit(1) from failing go test -short for the root package --- stations_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/stations_test.go b/stations_test.go index 832c8aa..4c33ed2 100644 --- a/stations_test.go +++ b/stations_test.go @@ -8,6 +8,8 @@ import ( "strings" "testing" + "github.com/gmgauthier/gostations/internal/config" + playerpkg "github.com/gmgauthier/gostations/internal/player" "github.com/gmgauthier/gostations/internal/radio" ver "github.com/gmgauthier/gostations/internal/version" ) @@ -82,6 +84,14 @@ func TestPrecheck_Unit(t *testing.T) { t.Parallel() t.Log("✓ Fast precheck unit test") + p := "mpv" + if v, err := config.Get("player.command"); err == nil && v != "" { + p = v + } + if !playerpkg.IsInstalled(p) { + t.Skipf("%s is either not installed, or not on your $PATH; skipping real precheck() call in unit test (see TestPrecheck_Live)", p) + } + // Simple smoke test — calls the real precheck() in the common "player installed" path // (no mocking of globals — that's not allowed in Go) precheck()