From 69f1a38e9f874500f42e055eb271665c5122d720 Mon Sep 17 00:00:00 2001 From: Ray Slakinski <19767+rays@users.noreply.github.com> Date: Fri, 13 Nov 2026 08:33:32 -0500 Subject: [PATCH] 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 --- ios/Tests/CarTests.swift | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/ios/Tests/CarTests.swift b/ios/Tests/CarTests.swift index f0beadb..57991cb 100644 --- a/ios/Tests/CarTests.swift +++ b/ios/Tests/CarTests.swift @@ -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) + } }