docs: clarify player integration test coverage
- commit
- 0db6373b0bcb9aec5e0e601f2ed7b0bde394a986
- author
- brice · · 2026-04-10 03:44 UTC
- parent
- 7618928
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
2 files · +24 -4
M README.md +3 -1
| @@ -41,6 +41,8 @@ The sync script is currently a placeholder for the planned header-import workflo | |||
| 41 | 41 | ||
| 42 | 42 | ## Integration tests | |
| 43 | 43 | ||
| 44 | - | Run integration tests (requires PipeWire runtime): | |
| 44 | + | Tagged integration tests require a **real PipeWire runtime/daemon** and verify the public lifecycle API against a live runtime: | |
| 45 | 45 | ||
| 46 | 46 | go test -tags integration ./integration ./pipewire -v | |
| 47 | + | ||
| 48 | + | These tests exercise state transitions (Idle → Playing → Stopped → Closed) through an actual PipeWire instance. Deeper cleanup internals are primarily covered by unit tests that use mocked dependencies. | |
| @@ -41,6 +41,8 @@ The sync script is currently a placeholder for the planned header-import workflo | |||||
| 41 | 41 | ||||
| 42 | ## Integration tests | 42 | ## Integration tests | ||
| 43 | 43 | ||||
| 44 | - | Run integration tests (requires PipeWire runtime): | 44 | + | Tagged integration tests require a **real PipeWire runtime/daemon** and verify the public lifecycle API against a live runtime: |
| 45 | 45 | ||||
| 46 | go test -tags integration ./integration ./pipewire -v | 46 | go test -tags integration ./integration ./pipewire -v | ||
| 47 | + | ||||
| 48 | + | These tests exercise state transitions (Idle → Playing → Stopped → Closed) through an actual PipeWire instance. Deeper cleanup internals are primarily covered by unit tests that use mocked dependencies. | |||
M integration/player_test.go +21 -3
| @@ -8,6 +8,10 @@ import ( | |||
| 8 | 8 | "github.com/bnema/purego-pipewire/pipewire" | |
| 9 | 9 | ) | |
| 10 | 10 | ||
| 11 | + | // TestPlayerStartStopClose verifies the player lifecycle against a real PipeWire | |
| 12 | + | // daemon. This test requires a running PipeWire runtime and only validates | |
| 13 | + | // externally visible state transitions (Idle -> Playing -> Stopped -> Closed). | |
| 14 | + | // Deeper cleanup internals are covered by unit tests. | |
| 11 | 15 | func TestPlayerStartStopClose(t *testing.T) { | |
| 12 | 16 | // Initialize PipeWire | |
| 13 | 17 | initResult, err := pipewire.Init() | |
| @@ -36,18 +40,32 @@ func TestPlayerStartStopClose(t *testing.T) { | |||
| 36 | 40 | t.Fatalf("NewPlayer returned error: %v", err) | |
| 37 | 41 | } | |
| 38 | 42 | ||
| 39 | - | // Test Start | |
| 43 | + | // Verify initial state is Idle | |
| 44 | + | if state := player.State(); state != pipewire.PlayerStateIdle { | |
| 45 | + | t.Errorf("Expected initial state Idle, got %v", state) | |
| 46 | + | } | |
| 47 | + | ||
| 48 | + | // Test Start - should transition to Playing state | |
| 40 | 49 | if err := player.Start(); err != nil { | |
| 41 | 50 | t.Errorf("Start returned error: %v", err) | |
| 42 | 51 | } | |
| 52 | + | if state := player.State(); state != pipewire.PlayerStatePlaying { | |
| 53 | + | t.Errorf("After Start: expected state Playing, got %v", state) | |
| 54 | + | } | |
| 43 | 55 | ||
| 44 | - | // Test Stop | |
| 56 | + | // Test Stop - should transition to Stopped state | |
| 45 | 57 | if err := player.Stop(); err != nil { | |
| 46 | 58 | t.Errorf("Stop returned error: %v", err) | |
| 47 | 59 | } | |
| 60 | + | if state := player.State(); state != pipewire.PlayerStateStopped { | |
| 61 | + | t.Errorf("After Stop: expected state Stopped, got %v", state) | |
| 62 | + | } | |
| 48 | 63 | ||
| 49 | - | // Test Close | |
| 64 | + | // Test Close - should transition to Closed state | |
| 50 | 65 | if err := player.Close(); err != nil { | |
| 51 | 66 | t.Errorf("Close returned error: %v", err) | |
| 52 | 67 | } | |
| 68 | + | if state := player.State(); state != pipewire.PlayerStateClosed { | |
| 69 | + | t.Errorf("After Close: expected state Closed, got %v", state) | |
| 70 | + | } | |
| 53 | 71 | } | |
| @@ -8,6 +8,10 @@ import ( | |||||
| 8 | "github.com/bnema/purego-pipewire/pipewire" | 8 | "github.com/bnema/purego-pipewire/pipewire" | ||
| 9 | ) | 9 | ) | ||
| 10 | 10 | ||||
| 11 | + | // TestPlayerStartStopClose verifies the player lifecycle against a real PipeWire | |||
| 12 | + | // daemon. This test requires a running PipeWire runtime and only validates | |||
| 13 | + | // externally visible state transitions (Idle -> Playing -> Stopped -> Closed). | |||
| 14 | + | // Deeper cleanup internals are covered by unit tests. | |||
| 11 | func TestPlayerStartStopClose(t *testing.T) { | 15 | func TestPlayerStartStopClose(t *testing.T) { | ||
| 12 | // Initialize PipeWire | 16 | // Initialize PipeWire | ||
| 13 | initResult, err := pipewire.Init() | 17 | initResult, err := pipewire.Init() | ||
| @@ -36,18 +40,32 @@ func TestPlayerStartStopClose(t *testing.T) { | |||||
| 36 | t.Fatalf("NewPlayer returned error: %v", err) | 40 | t.Fatalf("NewPlayer returned error: %v", err) | ||
| 37 | } | 41 | } | ||
| 38 | 42 | ||||
| 39 | - | // Test Start | 43 | + | // Verify initial state is Idle |
| 44 | + | if state := player.State(); state != pipewire.PlayerStateIdle { | |||
| 45 | + | t.Errorf("Expected initial state Idle, got %v", state) | |||
| 46 | + | } | |||
| 47 | + | ||||
| 48 | + | // Test Start - should transition to Playing state | |||
| 40 | if err := player.Start(); err != nil { | 49 | if err := player.Start(); err != nil { | ||
| 41 | t.Errorf("Start returned error: %v", err) | 50 | t.Errorf("Start returned error: %v", err) | ||
| 42 | } | 51 | } | ||
| 52 | + | if state := player.State(); state != pipewire.PlayerStatePlaying { | |||
| 53 | + | t.Errorf("After Start: expected state Playing, got %v", state) | |||
| 54 | + | } | |||
| 43 | 55 | ||||
| 44 | - | // Test Stop | 56 | + | // Test Stop - should transition to Stopped state |
| 45 | if err := player.Stop(); err != nil { | 57 | if err := player.Stop(); err != nil { | ||
| 46 | t.Errorf("Stop returned error: %v", err) | 58 | t.Errorf("Stop returned error: %v", err) | ||
| 47 | } | 59 | } | ||
| 60 | + | if state := player.State(); state != pipewire.PlayerStateStopped { | |||
| 61 | + | t.Errorf("After Stop: expected state Stopped, got %v", state) | |||
| 62 | + | } | |||
| 48 | 63 | ||||
| 49 | - | // Test Close | 64 | + | // Test Close - should transition to Closed state |
| 50 | if err := player.Close(); err != nil { | 65 | if err := player.Close(); err != nil { | ||
| 51 | t.Errorf("Close returned error: %v", err) | 66 | t.Errorf("Close returned error: %v", err) | ||
| 52 | } | 67 | } | ||
| 68 | + | if state := player.State(); state != pipewire.PlayerStateClosed { | |||
| 69 | + | t.Errorf("After Close: expected state Closed, got %v", state) | |||
| 70 | + | } | |||
| 53 | } | 71 | } | ||