Add Drive-In tickets and in-app reminders (0.71.0)
pauljd/davidson-ci: Davidson CI / quality (push) Failing after 1m38s
pauljd/davidson-ci: Davidson CI / ai-review (push) Failing after 1m32s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-11-02 13:03:28 +00:00
co-authored by Claude Opus 5.5
parent e4105eebeb
commit 7e42e65fb3
9 changed files with 173 additions and 22 deletions
@@ -107,4 +107,42 @@ class DriveInTest {
assertEquals("Alien and Aliens", all.first { it.kind == DriveInKind.Double }.title)
assertTrue(all.first { it.kind == DriveInKind.Marquee }.title.startsWith("Big"))
}
private fun tonight() = driveInBills(planDriveIn(null, big, late, bills, at(2, 10), london)!!, london)
private val minute = 60_000L
@Test fun aReminderComesFiveMinutesBeforeAndAgainAtTheStart() {
val all = tonight(); val show = all.first()
val tickets = mapOf(show.startMs to 0)
assertNull(driveInReminderDue(all, tickets, show.startMs - 6 * minute))
assertEquals(1, driveInReminderDue(all, tickets, show.startMs - 5 * minute)!!.stage)
assertEquals(2, driveInReminderDue(all, tickets, show.startMs)!!.stage)
assertNull(driveInReminderDue(all, mapOf(show.startMs to 1), show.startMs - minute))
assertEquals(2, driveInReminderDue(all, mapOf(show.startMs to 1), show.startMs)!!.stage)
assertNull(driveInReminderDue(all, mapOf(show.startMs to 2), show.startMs))
}
@Test fun noTicketMeansNoReminderAndALateOneStops() {
val all = tonight(); val show = all.first()
assertNull(driveInReminderDue(all, emptyMap(), show.startMs))
assertNull(driveInReminderDue(all, mapOf(show.startMs to 0), show.startMs + REMINDER_LATE_MS))
}
@Test fun ticketsSurviveARestartAndOldOnesDropOff() {
val folder = java.nio.file.Files.createTempDirectory("tickets").toFile()
val store = ScheduleStore(folder)
store.saveTickets("user", mapOf(5_000L to 1))
assertEquals(mapOf(5_000L to 1), ScheduleStore(folder).loadTickets("user"))
assertTrue(store.loadTickets("someone-else").isEmpty())
assertEquals(setOf(at(2, 20)), liveTickets(mapOf(at(2, 20) to 0, at(1, 2) to 0), at(2, 10)).keys)
}
@Test fun forgettingTheAccountKeepsTheNumberMoveDone() {
val folder = java.nio.file.Files.createTempDirectory("clear").toFile()
migrateChannelNumbers(folder)
ScheduleStore(folder).clear()
java.io.File(folder, "schedule-102.json").writeText("""{"channel":102}""")
migrateChannelNumbers(folder)
assertTrue(java.io.File(folder, "schedule-102.json").exists())
}
}