playlist retry-exhaustion handling

This commit is contained in:
Dmitry Sergeev
2026-09-01 23:35:41 +03:00
parent abdfc8e2de
commit 179768ca4a
9 changed files with 346 additions and 45 deletions
+5 -2
View File
@@ -14,6 +14,7 @@ import (
func TestDecodePlaylistFile(t *testing.T) {
input := `{
"loop": true,
"on_failure": "next",
"entries": [
{
"name": "sync",
@@ -44,7 +45,8 @@ func TestDecodePlaylistFile(t *testing.T) {
t.Fatalf("decodePlaylistFile() error = %v", err)
}
want := playback.Playlist{
Loop: true,
Loop: true,
OnFailure: playback.PlaylistFailureNext,
Entries: []playback.PlaylistEntry{
{
Name: "sync",
@@ -69,7 +71,7 @@ func TestDecodePlaylistFile(t *testing.T) {
},
},
}
if len(got.Entries) != len(want.Entries) || got.Loop != want.Loop {
if len(got.Entries) != len(want.Entries) || got.Loop != want.Loop || got.OnFailure != want.OnFailure {
t.Fatalf("decodePlaylistFile() = %#v, want %#v", got, want)
}
for index := range want.Entries {
@@ -100,6 +102,7 @@ func TestDecodePlaylistFileRejectsInvalidInput(t *testing.T) {
{name: "malformed JSON", input: `{"entries": [`, wantText: "decode JSON"},
{name: "unknown field", input: `{"unknown": true}`, wantText: "unknown field"},
{name: "multiple roots", input: `{"entries": []} {"entries": []}`, wantText: "multiple root values"},
{name: "invalid failure policy", input: `{"on_failure":"skip","entries":[]}`, wantErr: playback.ErrPlaylistFailurePolicy},
{
name: "invalid duration",
input: `{"entries":[{"video":{"domain":"/video","uuid":"video"},"duration":"later"}]}`,