test(player): cover NowPlayingRevision advancing for both poll and event

The rebase derives NowPlayingRevision from the existing FieldNowPlaying
generation rather than a counter of its own. Nothing asserted that it
advances down both paths that write the field, a completed poll and a push
event, which is the property the player's readback loop depends on to tell
a fresh now-playing write from an unrelated field's merge.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Tobias Gesellchen
2026-09-05 20:36:58 +02:00
co-authored by Claude Opus 5
parent a4177ec6f2
commit a3b4036627
@@ -72,6 +72,29 @@ func TestUnrelatedProjectionDoesNotAdvanceNowPlayingRevision(t *testing.T) {
}
}
func TestNowPlayingRevisionAdvancesForPollAndEvent(t *testing.T) {
conn := NewDeviceConnection(nil, nil)
baseline := conn.Status().NowPlayingRevision
generation := conn.BeginFieldPoll(FieldNowPlaying)
conn.CompleteFieldPoll(FieldNowPlaying, generation, func(status *DeviceStatus) {
status.NowPlaying = &models.NowPlaying{Source: "AUX"}
})
polled := conn.Status().NowPlayingRevision
if polled <= baseline {
t.Fatalf("now-playing revision after poll = %d, want newer than %d", polled, baseline)
}
conn.ApplyFieldEvent(FieldNowPlaying, func(status *DeviceStatus) {
status.NowPlaying = &models.NowPlaying{Source: "SPOTIFY"}
})
if got := conn.Status().NowPlayingRevision; got <= polled {
t.Fatalf("now-playing revision after event = %d, want newer than %d", got, polled)
}
}
func TestDeviceStatusRevisionIsMonotonicWithConcurrentProjections(t *testing.T) {
conn := NewDeviceConnection(nil, nil)
const projections = 64