Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions ios/Tests/GutenbergKitTests/Media/MediaUploadServerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ struct MediaUploadServerTests {
// those reads: a file admitted for processing was forwarded unprocessed. The
// host dropping it before the request is the same condition, deterministically.
let mockUploader = MockInternalMediaClient()
var processor: TranscodingProcessor? = TranscodingProcessor()
var processor: ResizingProcessor? = ResizingProcessor()
weak let weakProcessor = processor
let server = try await MediaUploadServer.start(processor: processor, internalClient: mockUploader)
defer { server.stop() }
Expand Down Expand Up @@ -1143,28 +1143,14 @@ private final class RecordingUploader: MediaUploader, @unchecked Sendable {

/// An uploader whose delivery fails terminally, as one would after exhausting its own
/// post-process recovery and force-deleting the orphan.
private final class ThrowingUploader: MediaUploader, @unchecked Sendable {
private final class ThrowingUploader: MediaUploader {
struct Failure: Error {}

func upload(_ upload: MediaUpload) async throws -> Data {
throw Failure()
}
}

/// A processor that transcodes, used to check the server holds it across the whole
/// request rather than re-reading a reference the host may have dropped.
private final class TranscodingProcessor: MediaProcessor, @unchecked Sendable {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finding from Claude:

Consolidating onto one mock is right, but this deletes the better name. The survivor, ResizingProcessor (:1196), returns .processed(_, mimeType: "video/mp4", filename: "clip.mp4") — a transcode, not a resize — and processesThenDelivers feeds it photo.jpg/image/jpeg. Android's equivalent mock is still TranscodingProcessor (MediaUploadServerTest.kt:1002), so a repo-wide grep for that name now returns Android only.

Worth catching while you're here: 42bdb8d2 inserted ValueTypeProcessor between the transcode doc comment and the class it described, so :1184 now stacks two doc comments on ValueTypeProcessor and leaves ResizingProcessor with none.

Renaming the survivor to TranscodingProcessor and re-attaching that comment would make this a pure consolidation and restore parity with Android.

func handlesFile(ofType mimeType: String, named filename: String) -> Bool {
true
}

func processFile(at url: URL, mimeType: String, filename: String) async throws -> ProcessedProxyFile {
let processed = FileManager.default.temporaryDirectory.appendingPathComponent("clip.mp4")
try? Data("transcoded".utf8).write(to: processed)
return .processed(processed, mimeType: "video/mp4", filename: "clip.mp4")
}
}

private final class ProcessOnlyProcessor: MediaProcessor, @unchecked Sendable {
private let lock = NSLock()
private var _processFileCalled = false
Expand Down
Loading