Publish current app and server

This commit is contained in:
ponzischeme89
2026-08-02 22:10:19 +12:00
parent a265636139
commit 1ed180c739
203 changed files with 23933 additions and 2788 deletions
+57 -3
View File
@@ -59,8 +59,10 @@ func TestBuildPrerollScheduleSplitsTodayAndWeek(t *testing.T) {
thursday := time.Date(2026, 7, 30, 19, 0, 0, 0, location).UTC()
schedule := buildPrerollSchedule([]sonarr.Episode{
{
SeasonNumber: 1, EpisodeNumber: 4, Title: "Tonight",
AirDateUTC: &today, Series: sonarr.Series{Title: "Northbound"},
ID: 14, SeriesID: 7, SeasonNumber: 1, EpisodeNumber: 4, Title: "Tonight",
AirDateUTC: &today, Series: sonarr.Series{
ID: 7, Title: "Northbound", Images: []sonarr.Image{{CoverType: "fanart"}},
},
},
{
SeasonNumber: 2, EpisodeNumber: 1, Title: "Later",
@@ -69,7 +71,8 @@ func TestBuildPrerollScheduleSplitsTodayAndWeek(t *testing.T) {
}, now, location)
if len(schedule.Today) != 1 || schedule.Today[0].Series != "Northbound" ||
schedule.Today[0].Schedule != "8:30 PM" {
schedule.Today[0].Schedule != "8:30 PM" || schedule.Today[0].ItemID != "sonarr:7:14" ||
schedule.Today[0].ImageType != "backdrop" {
t.Fatalf("unexpected today schedule: %+v", schedule.Today)
}
if len(schedule.ThisWeek) != 1 || schedule.ThisWeek[0].EpisodeCode != "S02E01" ||
@@ -77,3 +80,54 @@ func TestBuildPrerollScheduleSplitsTodayAndWeek(t *testing.T) {
t.Fatalf("unexpected week schedule: %+v", schedule.ThisWeek)
}
}
func TestBuildSonarrRowCoversFiveDaysAndUsesRelativeAirLabels(t *testing.T) {
location := time.FixedZone("NZST", 12*60*60)
now := time.Date(2026, 7, 29, 8, 0, 0, 0, location)
episode := func(id int, air time.Time) sonarr.Episode {
utc := air.UTC()
return sonarr.Episode{
ID: id, SeriesID: id, SeasonNumber: 1, EpisodeNumber: id,
Title: "Episode", AirDateUTC: &utc,
Series: sonarr.Series{ID: id, Title: "Show"},
}
}
row, err := buildSonarrRow([]sonarr.Episode{
episode(1, time.Date(2026, 7, 29, 16, 0, 0, 0, location)),
episode(2, time.Date(2026, 7, 30, 16, 0, 0, 0, location)),
episode(3, time.Date(2026, 8, 2, 16, 0, 0, 0, location)),
episode(4, time.Date(2026, 8, 3, 16, 0, 0, 0, location)),
}, now, location)
if err != nil {
t.Fatal(err)
}
if row.Title != "Shows airing in the next 5 days" || len(row.Items) != 3 {
t.Fatalf("five-day row = %+v", row)
}
labels := make([]string, 0, len(row.Items))
dayLabels := make([]string, 0, len(row.Items))
for _, raw := range row.Items {
var item sonarrScheduleItem
if err := json.Unmarshal(raw, &item); err != nil {
t.Fatal(err)
}
labels = append(labels, item.MembyAirLabel)
dayLabels = append(dayLabels, item.MembyAirDayLabel)
}
want := []string{
"In 8 hours (4:00 PM)",
"Tomorrow: 4:00 PM",
"Sunday: 4:00 PM",
}
for i := range want {
if labels[i] != want[i] {
t.Fatalf("labels = %#v, want %#v", labels, want)
}
}
wantDays := []string{"Today", "Tomorrow", "Sunday"}
for i := range wantDays {
if dayLabels[i] != wantDays[i] {
t.Fatalf("day labels = %#v, want %#v", dayLabels, wantDays)
}
}
}