Rework the guide grid and stop loop programmes overlapping the plan (0.52.0)
pauljd/davidson-ci: Davidson CI / quality (push) Failing after 1m35s
pauljd/davidson-ci: Davidson CI / ai-review (push) Failing after 1m23s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-11-02 09:23:06 +00:00
co-authored by Claude Opus 5.5
parent de071af4a8
commit 11500dfae6
7 changed files with 58 additions and 29 deletions
@@ -450,4 +450,23 @@ class ChannelScheduleTest {
topUpPlan(first, ScheduleCursor(), pool, now + minute, avoid = { _, _, _ -> asked = true; false })
assertFalse(asked)
}
@Test fun theLoopNeverRunsOverThePlansFirstProgramme() {
val longLoop = SampleChannel(listOf(ScheduledMedia(SampleItem("x", "Episode", 60, "", "x", 60 * minute), "s-x", 60 * minute),
ScheduledMedia(SampleItem("y", "Episode", 60, "", "y", 60 * minute), "s-y", 60 * minute)), "Paradox", 152)
val plan = topUpPlan(null, ScheduleCursor(), pool, now)!!
val channel = ScheduledChannel(longLoop, plan)
val before = channel.at(now - minute)
assertEquals(now, before.endMs)
val cells = guideCells(channel, now - 30 * minute, now + 60 * minute)
assertTrue(cells.zipWithNext().all { (a, b) -> a.show.endMs <= b.show.startMs })
assertEquals(plan.entries.first().media, cells.first { it.show.startMs >= now }.show.media)
}
@Test fun onlyTheProgrammeOnAirIsLit() {
assertEquals(GuideCellTime.Past, guideCellTime(100, 200, 200))
assertEquals(GuideCellTime.Now, guideCellTime(100, 200, 100))
assertEquals(GuideCellTime.Now, guideCellTime(100, 200, 199))
assertEquals(GuideCellTime.Later, guideCellTime(100, 200, 99))
}
}