Surface the existing pin (keep-from-cull) and per-file delete actions as visible inline buttons on each offline cache row instead of context-menu-only: a star toggles protection from auto-cull (and restore-if-missing), a trash culls that file early. Aligns wording/icons to the star metaphor. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
59 lines
No EOL
2.8 KiB
Swift
59 lines
No EOL
2.8 KiB
Swift
import XCTest
|
|
@testable import TVAnarchyCore
|
|
|
|
final class TitleLibraryTests: XCTestCase {
|
|
private var tmp: URL!
|
|
private var store: TitleLibraryStore!
|
|
|
|
override func setUp() {
|
|
tmp = FileManager.default.temporaryDirectory
|
|
.appendingPathComponent("tv-anarchy-titlelib-\(UUID().uuidString)", isDirectory: true)
|
|
try? FileManager.default.createDirectory(at: tmp, withIntermediateDirectories: true)
|
|
setenv("TV_ANARCHY_STATE_DIR", tmp.path, 1)
|
|
store = TitleLibraryStore()
|
|
TitleLibrary.store = store
|
|
}
|
|
|
|
override func tearDown() {
|
|
unsetenv("TV_ANARCHY_STATE_DIR")
|
|
try? FileManager.default.removeItem(at: tmp)
|
|
TitleLibrary.store = TitleLibraryStore()
|
|
}
|
|
|
|
func testRoundTripRowByContentKey() {
|
|
let key = ContentID.canonical(work: "Psych", season: 1, episode: 4)
|
|
let row = store.observe(TitleObservation(contentKey: key, showName: "Psych",
|
|
season: 1, episode: 4,
|
|
episodeTitle: "Shawn vs. the Red Phantom",
|
|
provenance: .tvmaze, confidence: 0.92,
|
|
sources: ["tvmaze:ep-12345"]))
|
|
XCTAssertEqual(row.contentKey, key)
|
|
XCTAssertEqual(row.episodeTitle, "Shawn vs. the Red Phantom")
|
|
XCTAssertEqual(row.displayName, "S01E04 · Shawn vs. the Red Phantom")
|
|
XCTAssertEqual(store.lookup(key)?.provenance, .tvmaze)
|
|
}
|
|
|
|
func testManualBeatsMLX() {
|
|
let key = "psych/s01e04"
|
|
_ = store.observe(TitleObservation(contentKey: key, showName: "Psych",
|
|
season: 1, episode: 4,
|
|
episodeTitle: "MLX Guess", provenance: .mlx,
|
|
confidence: 0.7))
|
|
let merged = store.observe(TitleObservation(contentKey: key, showName: "Psych",
|
|
season: 1, episode: 4,
|
|
episodeTitle: "Shawn vs. the Red Phantom",
|
|
provenance: .manual))
|
|
XCTAssertEqual(merged.episodeTitle, "Shawn vs. the Red Phantom")
|
|
XCTAssertEqual(merged.provenance, .manual)
|
|
}
|
|
|
|
func testPersistsAcrossReload() {
|
|
let key = "daria/s03e01"
|
|
store.observe(TitleObservation(contentKey: key, showName: "Daria",
|
|
season: 3, episode: 1,
|
|
episodeTitle: "Through a Lens Darkly",
|
|
provenance: .regex))
|
|
let reloaded = TitleLibraryStore()
|
|
XCTAssertEqual(reloaded.lookup(key)?.episodeTitle, "Through a Lens Darkly")
|
|
}
|
|
} |