explicit info in GUI for playlist
This commit is contained in:
@@ -2,6 +2,7 @@ package playback
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
@@ -152,7 +153,15 @@ func TestPlaylistControllerFailurePolicy(t *testing.T) {
|
||||
|
||||
commands <- PlaylistCommand{Kind: PlaylistSelect, Index: 0}
|
||||
<-sessions
|
||||
events <- PlaylistEvent{Revision: 1, Kind: PlaylistEventFailed}
|
||||
failureErr := errors.New("flow unavailable")
|
||||
events <- PlaylistEvent{
|
||||
Revision: 1,
|
||||
Kind: PlaylistEventFailed,
|
||||
Failure: Status{
|
||||
Unit: UnitVideo, State: StateFailed,
|
||||
Attempt: 2, FailedAttempts: 2, Err: failureErr,
|
||||
},
|
||||
}
|
||||
|
||||
if test.wantAdvance {
|
||||
select {
|
||||
@@ -160,16 +169,23 @@ func TestPlaylistControllerFailurePolicy(t *testing.T) {
|
||||
case <-time.After(time.Second):
|
||||
t.Fatal("failure did not advance playlist")
|
||||
}
|
||||
snapshot, _ := controller.Snapshot()
|
||||
snapshot := waitForPlaylistSnapshot(t, controller, func(snapshot PlaylistSnapshot) bool {
|
||||
return snapshot.State.CurrentIndex == 1 && snapshot.Revision == 2
|
||||
})
|
||||
if snapshot.State.CurrentIndex != 1 || snapshot.Revision != 2 {
|
||||
t.Fatalf("snapshot = %#v, want index 1 revision 2", snapshot)
|
||||
}
|
||||
assertPlaylistFailure(t, snapshot, failureErr)
|
||||
} else {
|
||||
select {
|
||||
case command := <-sessions:
|
||||
t.Fatalf("unexpected session command: %#v", command)
|
||||
case <-time.After(20 * time.Millisecond):
|
||||
}
|
||||
snapshot := waitForPlaylistSnapshot(t, controller, func(snapshot PlaylistSnapshot) bool {
|
||||
return snapshot.HasFailure
|
||||
})
|
||||
assertPlaylistFailure(t, snapshot, failureErr)
|
||||
}
|
||||
|
||||
cancel()
|
||||
@@ -179,3 +195,16 @@ func TestPlaylistControllerFailurePolicy(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func assertPlaylistFailure(t *testing.T, snapshot PlaylistSnapshot, wantErr error) {
|
||||
t.Helper()
|
||||
if !snapshot.HasFailure {
|
||||
t.Fatal("snapshot has no playlist failure")
|
||||
}
|
||||
failure := snapshot.Failure
|
||||
if failure.EntryIndex != 0 || failure.EntryName != "first" ||
|
||||
failure.Status.Unit != UnitVideo || failure.Status.Attempt != 2 ||
|
||||
failure.Status.FailedAttempts != 2 || !errors.Is(failure.Status.Err, wantErr) {
|
||||
t.Fatalf("failure = %#v", failure)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user