Server move guarantees: unmatched titles remembered, no duplicates, ambiguous ones wait for you (build 66)
Paul, 18 November 2026: three permanent guarantees. A title nothing matched is kept in the new server's workspace (moved-pending-0.json) and comes back by itself when the library has it (recheck, from what the TV knows; no scan). A title with more than one possible match waits for your choice, and only one of its possible matches is accepted. Running the move again adds nothing: approvals by title, your channels by name, decisions, viewing and the pending list are all checked first. Rollback forgets what the move remembered. adb: move-pending, move-resolve, move-recheck. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -179,6 +179,56 @@ class ServerMoveTest {
|
||||
assertTrue(move(r).preview().channels.single { it.number == 305 }.add.none { it.title == "Tremors" })
|
||||
}
|
||||
|
||||
// --- Paul's three guarantees (18 November 2026) ---
|
||||
|
||||
@Test fun runningTheMoveTwiceNeverDuplicatesAnything() {
|
||||
val r = rig()
|
||||
move(r).let { it.apply(it.preview().signature) }
|
||||
val choices = File(r.to, "choices-305.json").readText(); val yours = File(r.to, "yours.json").readText()
|
||||
val again = move(r, emptySet()); val plan = again.preview()
|
||||
assertEquals(0, plan.adds); assertTrue(plan.yours.isEmpty()); assertTrue(plan.decisions.isEmpty()); assertTrue(plan.pending.isEmpty())
|
||||
again.apply(plan.signature)
|
||||
assertEquals(choices, File(r.to, "choices-305.json").readText())
|
||||
assertEquals(yours, File(r.to, "yours.json").readText())
|
||||
assertEquals(1, loadDecisions(ScheduleStore(r.to).decisionsFile()).size)
|
||||
assertEquals(1, TasteStore(File(r.to, "taste")).events("grown").size)
|
||||
assertEquals(2, PendingTitle.load(r.to).size) // Robin Redbreast and Cosmos, once each
|
||||
}
|
||||
|
||||
@Test fun anAmbiguousTitleWaitsForYourChoiceAndOnlyAPossibleMatchIsAccepted() {
|
||||
val r = rig()
|
||||
move(r).let { it.apply(it.preview().signature) }
|
||||
val cosmos = PendingTitle.load(r.to).single { it.ambiguous }
|
||||
assertEquals("Cosmos", cosmos.title)
|
||||
assertTrue(ScheduleStore(r.to).loadChoices(newUser, 305).accepted.none { it.title == "Cosmos" }) // never guessed
|
||||
assertTrue(PendingTitle.resolve(r.to, newUser, cosmos.key, "9500").startsWith("refused")) // not one of its matches
|
||||
PendingTitle.resolve(r.to, newUser, cosmos.key, "9004")
|
||||
val added = ScheduleStore(r.to).loadChoices(newUser, 305).accepted.single { it.title == "Cosmos" }
|
||||
assertEquals("tvdb.2", added.ref)
|
||||
assertTrue(PendingTitle.load(r.to).none { it.ambiguous })
|
||||
assertTrue(PendingTitle.resolve(r.to, newUser, cosmos.key, "9004").startsWith("refused")) // once only
|
||||
}
|
||||
|
||||
@Test fun anUnmatchedTitleIsRememberedAndComesBackWhenTheLibraryHasIt() {
|
||||
val r = rig()
|
||||
move(r).let { it.apply(it.preview().signature) }
|
||||
assertEquals("Robin Redbreast", PendingTitle.load(r.to).single { !it.ambiguous }.title)
|
||||
assertEquals(0, PendingTitle.recheck(r.to, newUser, newCat)) // still not there
|
||||
val arrived = MemoryMoveCatalogue(sequenceOf(film("9900", "Robin Redbreast", 1970, "imdb" to "tt0066303")))
|
||||
assertEquals(1, PendingTitle.recheck(r.to, newUser, arrived))
|
||||
val back = ScheduleStore(r.to).loadChoices(newUser, 305).accepted.single { it.title == "Robin Redbreast" }
|
||||
assertEquals("imdb.tt0066303", back.ref); assertEquals("late", back.group)
|
||||
assertTrue(PendingTitle.load(r.to).none { it.title == "Robin Redbreast" })
|
||||
assertEquals(0, PendingTitle.recheck(r.to, newUser, arrived)) // and only once
|
||||
}
|
||||
|
||||
@Test fun rollbackAlsoForgetsWhatTheMoveRemembered() {
|
||||
val r = rig(); val m = move(r)
|
||||
val receipt = m.apply(m.preview().signature)
|
||||
ServerMove.rollback(r.to, receipt)
|
||||
assertTrue(PendingTitle.load(r.to).isEmpty())
|
||||
}
|
||||
|
||||
private fun snapshot(dir: File): Map<String, String> =
|
||||
dir.walk().filter { it.isFile && !it.name.endsWith(".prev") && !it.name.endsWith(".tmp") }.associate { it.relativeTo(dir).path to it.readText() }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user