iOS tests: CarPlay's episodes need a downloaded file (#443)

6d6bfe6 added Enclosure.path, which the tests' enclosures lacked, so the
test target no longer built. They now have one, and a test checks that a
picture and a file not yet fetched are passed over.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ray Slakinski
2026-11-13 08:33:32 -05:00
parent 6d6bfe6e1d
commit 69f1a38e9f

View File

@@ -10,8 +10,8 @@ final class CarTests: XCTestCase {
let e = try episode("""
{"guid":"g","feed_id":"f","title":null,"link":null,"image":null,"duration":1800,"position":600,
"read":false,"flagged":false,"enclosures":[
{"id":7,"feed_id":"f","guid":"g","url":"https://x/v.mp4","mime":"video/mp4","state":"done"},
{"id":8,"feed_id":"f","guid":"g","url":"https://x/Show%20Ep%201.mp3","mime":"audio/mpeg","state":"done"}]}
{"id":7,"feed_id":"f","guid":"g","url":"https://x/v.mp4","mime":"video/mp4","path":"/d/v.mp4","state":"done"},
{"id":8,"feed_id":"f","guid":"g","url":"https://x/Show%20Ep%201.mp3","mime":"audio/mpeg","path":"/d/e.mp3","state":"done"}]}
""")
XCTAssertEqual(e.audio?.id, 8, "a video is passed over for the sound")
XCTAssertEqual(e.name, "Show Ep 1", "untitled is named by its file")
@@ -26,11 +26,24 @@ final class CarTests: XCTestCase {
}
func testTheFileIsTheOneThePageWouldPlay() {
let plain = CarEpisode.Enclosure(id: 4, url: "u", mime: nil, deadair: nil)
let trimmed = CarEpisode.Enclosure(id: 5, url: "u", mime: nil, deadair: 90)
let plain = CarEpisode.Enclosure(id: 4, url: "u", mime: nil, deadair: nil, path: "/d/a")
let trimmed = CarEpisode.Enclosure(id: 5, url: "u", mime: nil, deadair: 90, path: "/d/b")
XCTAssertEqual(CarEpisode.path(of: plain, kept: []), "/media/4")
XCTAssertEqual(CarEpisode.path(of: trimmed, kept: []), "/media/5/deadair.m3u8")
XCTAssertEqual(CarEpisode.path(of: trimmed, kept: ["/media/5/deadair"]), "/media/5/deadair",
"the copy on the phone, connection or not")
}
/// #443: only what ipx has downloaded, and only sound.
func testOnlyADownloadedSoundIsPlayable() throws {
let e = try episode("""
{"guid":"g","feed_id":"f","title":"T","position":0,"enclosures":[
{"id":1,"url":"https://x/cover.jpg","mime":"image/jpeg","path":"/d/c.jpg"},
{"id":2,"url":"https://x/later.mp3","mime":"audio/mpeg","path":null},
{"id":3,"url":"https://x/now.mp3","mime":null,"path":"/d/n.mp3"}]}
""")
XCTAssertEqual(e.audio?.id, 3, "a picture and a file not yet fetched are passed over; no type, an .mp3 name")
let blog = try episode(#"{"guid":"g","feed_id":"f","title":"T","position":0,"enclosures":[{"id":1,"url":"https://x/a.png","mime":"image/png","path":"/d/a.png"}]}"#)
XCTAssertNil(blog.audio)
}
}