0.99.12: one failed show in a pool refresh keeps its previous copy instead of losing the whole refresh; retry in 6 hours
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertSame
|
||||
import org.junit.Assert.assertThrows
|
||||
import org.junit.Test
|
||||
|
||||
/** One show's failed read keeps its previous copy; nothing is ever dropped, and an outage still keeps the whole old pool. */
|
||||
class PartialPoolReadTest {
|
||||
private fun show(title: String) = PoolSeries(title, title, listOf(PoolEpisode("$title-1", "s", EpisodeMark(1, 1), "E1", 1_800_000)))
|
||||
private val previous = listOf(show("X-Men: The Animated Series"), show("Batman Beyond"), show("Halloween"))
|
||||
private val timeout = EmbyCheckException("timed out", retryable = true)
|
||||
|
||||
@Test fun aFailedShowKeepsItsPreviousCopy() {
|
||||
val read = PartialRead(previous)
|
||||
assertSame(previous[0], read.carry(seriesKey("X-Men: The Animated Series"), timeout))
|
||||
// A film named with its year finds its plain-titled copy.
|
||||
assertSame(previous[2], read.carry(seriesKey(FilmIdentity.of("Halloween (1978)").title), timeout))
|
||||
assertEquals(2, read.carried)
|
||||
}
|
||||
|
||||
@Test fun nothingIsDroppedAndAnOutageAbandonsTheRefresh() {
|
||||
// No previous copy: the refresh is abandoned rather than lose the show.
|
||||
assertThrows(EmbyCheckException::class.java) { PartialRead(previous).carry(seriesKey("Static Shock"), timeout) }
|
||||
// A failure not worth retrying: abandoned.
|
||||
assertThrows(EmbyCheckException::class.java) { PartialRead(previous).carry(seriesKey("Batman Beyond"), EmbyCheckException("refused", 401)) }
|
||||
// More than three failures in one refresh means the provider is down: abandoned, so the whole old pool stays.
|
||||
val read = PartialRead(previous + (1..3).map { show("Show $it") })
|
||||
(1..3).forEach { read.carry(seriesKey("Show $it"), timeout) }
|
||||
assertThrows(EmbyCheckException::class.java) { read.carry(seriesKey("Batman Beyond"), timeout) }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user