0.3.32
This commit is contained in:
@@ -250,3 +250,57 @@ func TestBuildSonarrRowCoversFiveDaysAndUsesRelativeAirLabels(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolveNextAiringOnlyAnswersForContinuingShowsWithAFutureAiring(t *testing.T) {
|
||||
location := time.UTC
|
||||
now := time.Date(2026, 8, 26, 12, 0, 0, 0, location)
|
||||
tomorrow := now.AddDate(0, 0, 1)
|
||||
yesterday := now.AddDate(0, 0, -1)
|
||||
|
||||
catalogue := []sonarr.Series{
|
||||
{Title: "Continuing Show", Status: "continuing", NextAiring: &tomorrow},
|
||||
{Title: "Ended Show", Status: "ended", NextAiring: &tomorrow},
|
||||
{Title: "Cancelled Show", Status: "cancelled", NextAiring: &tomorrow},
|
||||
{Title: "No Schedule Show", Status: "continuing", NextAiring: nil},
|
||||
{Title: "Already Aired Show", Status: "continuing", NextAiring: &yesterday},
|
||||
}
|
||||
|
||||
if _, info, ok := resolveNextAiring(catalogue, "Continuing Show", now, location); !ok {
|
||||
t.Fatal("expected a continuing show with a future airing to resolve")
|
||||
} else if info.DayLabel != "Tomorrow" {
|
||||
t.Fatalf("day label = %q, want Tomorrow", info.DayLabel)
|
||||
}
|
||||
|
||||
cases := []string{
|
||||
"Ended Show", "Cancelled Show", "No Schedule Show", "Already Aired Show", "Unknown Show",
|
||||
}
|
||||
for _, name := range cases {
|
||||
if _, _, ok := resolveNextAiring(catalogue, name, now, location); ok {
|
||||
t.Fatalf("%q should not have produced a next-airing answer", name)
|
||||
}
|
||||
}
|
||||
|
||||
if _, _, ok := resolveNextAiring(catalogue, " ", now, location); ok {
|
||||
t.Fatal("a blank series name should never resolve")
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolveNextAiringWordingMatchesTheScheduleRow(t *testing.T) {
|
||||
location := time.FixedZone("NZST", 12*60*60)
|
||||
now := time.Date(2026, 7, 27, 8, 0, 0, 0, location)
|
||||
air := now.Add(8 * time.Hour)
|
||||
catalogue := []sonarr.Series{
|
||||
{Title: "Northbound", Status: "continuing", NextAiring: &air},
|
||||
}
|
||||
|
||||
_, info, ok := resolveNextAiring(catalogue, "Northbound", now, location)
|
||||
if !ok {
|
||||
t.Fatal("expected a resolved answer")
|
||||
}
|
||||
wantLabel := scheduleAirLabel(air, now, location)
|
||||
wantDayLabel := scheduleAirDayLabel(air, now, location)
|
||||
if info.Label != wantLabel || info.DayLabel != wantDayLabel {
|
||||
t.Fatalf("wording drifted from the schedule row: got %+v, want label=%q day=%q",
|
||||
info, wantLabel, wantDayLabel)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user