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
Some checks failed
CI / Test (push) Successful in 55s
CI / Build (push) Failing after 18s

This commit is contained in:
Greg Gauthier 2026-06-06 08:12:56 +01:00
parent fefc6b8a5f
commit 66b7f808f7

View File

@ -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()