- Fix 10 err113 violations: extract dynamic errors to package-level sentinels - Fix 12 errcheck violations: handle unchecked error returns in player, metadata, and config packages - Fix 4 revive stutter warnings: rename player.PlayerState to player.State, player.PlayerVolume to player.Volume, queue.QueueTrack to queue.Track, queue.QueueState to queue.State - Fix 2 staticcheck SA4001: simplify *&x to x in assets handler - Fix 5 unused constants: remove dead AudioFileType iota block in models - Fix gci/gofumpt/wsl formatting issues across multiple files - Add gofumpt module-path setting to .golangci.yml for correct import grouping - Fix player test: gate integration test behind YELLOWJACKET_INTEGRATION env var instead of only skipping in CI, and replace t.Errorf+t.Failed with t.Fatalf - Remove continue-on-error from golangci-lint CI step so linting is now required
53 lines
1.3 KiB
Go
53 lines
1.3 KiB
Go
package player
|
|
|
|
import (
|
|
"context"
|
|
"log/slog"
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
var testQueue = []string{
|
|
"../../test_data/music_library_test/other_music/03 PONPONPON.mp3",
|
|
"../../test_data/music_library_test/01 Some Chords.mp3",
|
|
"../../test_data/music_library_test/03 anything.mp3",
|
|
}
|
|
|
|
func TestPlayer(t *testing.T) {
|
|
// This is an integration test that requires:
|
|
// 1. A Wails runtime context (SetContext calls runtime.EventsOn)
|
|
// 2. An audio output device (speaker.Init)
|
|
//
|
|
// Skip unless the caller explicitly opts in via YELLOWJACKET_INTEGRATION=1.
|
|
if os.Getenv("YELLOWJACKET_INTEGRATION") == "" {
|
|
t.Skip(
|
|
"skipping: integration test requires Wails runtime and audio device (set YELLOWJACKET_INTEGRATION=1 to run)",
|
|
)
|
|
}
|
|
|
|
t.Logf("Starting test")
|
|
|
|
p, err := NewPlayer(context.Background(), slog.Default(), nil)
|
|
if err != nil {
|
|
t.Fatalf("could not create player: %s", err.Error())
|
|
}
|
|
|
|
// SetContext registers Wails event handlers; only works with a real Wails context.
|
|
p.SetContext(t.Context())
|
|
t.Logf("initializing player")
|
|
|
|
for _, track := range testQueue {
|
|
t.Logf("loading file: %s", track)
|
|
|
|
err = p.LoadFile(track)
|
|
if err != nil {
|
|
t.Fatalf("could not load file %s: %s", track, err.Error())
|
|
}
|
|
|
|
err = p.Play()
|
|
if err != nil {
|
|
t.Fatalf("could not play file %s: %s", track, err.Error())
|
|
}
|
|
}
|
|
}
|