Buckets:
localhost1978/localhost / LOCALHOST1978 /Modules /SSK_Orchestrator /Tests /SSK_OrchestratorTests /AudioACPCommandRouterTests.swift
| import Foundation | |
| import SSK_Abstractions | |
| @testable import SSK_Orchestrator | |
| import XCTest | |
| @available(macOS 27.0, iOS 27.0, *) | |
| final class AudioACPCommandRouterTests: XCTestCase { | |
| func testRoutesAllThreeTypedMethods() async throws { | |
| let service = FakeAudioIngestionService() | |
| let router = AudioACPCommandRouter(service: service) | |
| let ingestionRequest = makeIngestionRequest() | |
| let start = await router.handle( | |
| AudioACPCommandRequest( | |
| method: .ingestAudio, | |
| ingestionRequest: ingestionRequest | |
| ) | |
| ) | |
| XCTAssertTrue(start.isSuccess) | |
| let jobID = try XCTUnwrap(start.jobID) | |
| let status = await router.handle( | |
| AudioACPCommandRequest( | |
| method: .getAudioIngestion, | |
| jobID: jobID | |
| ) | |
| ) | |
| XCTAssertTrue(status.isSuccess) | |
| let cancel = await router.handle( | |
| AudioACPCommandRequest( | |
| method: .cancelAudioIngestion, | |
| jobID: jobID | |
| ) | |
| ) | |
| XCTAssertEqual(cancel.snapshot?.record.state, .cancelled) | |
| let callCount = await service.callCount | |
| XCTAssertEqual(callCount, 3) | |
| } | |
| func testRejectsMalformedAndOversizedWireRequests() async throws { | |
| let router = AudioACPCommandRouter(service: FakeAudioIngestionService()) | |
| let malformedData = await router.handle(encodedRequest: Data("{".utf8)) | |
| let malformed = try JSONDecoder().decode( | |
| AudioACPCommandResponse.self, | |
| from: malformedData | |
| ) | |
| XCTAssertNil(malformed.requestURI) | |
| XCTAssertEqual(malformed.failure?.code, .invalidRequest) | |
| let oversizedData = await router.handle( | |
| encodedRequest: Data( | |
| repeating: 0, | |
| count: AudioACPCommandRouter.maximumRequestByteCount + 1 | |
| ) | |
| ) | |
| let oversized = try JSONDecoder().decode( | |
| AudioACPCommandResponse.self, | |
| from: oversizedData | |
| ) | |
| XCTAssertNil(oversized.requestURI) | |
| XCTAssertEqual(oversized.failure?.code, .invalidRequest) | |
| } | |
| private func makeIngestionRequest() -> AudioIngestionRequest { | |
| AudioIngestionRequest( | |
| source: .securityScopedBookmark( | |
| data: Data([1]), | |
| displayName: "fixture.wav", | |
| contentTypeIdentifier: "com.microsoft.waveform-audio" | |
| ), | |
| mode: .postProduction | |
| ) | |
| } | |
| } | |
| @available(macOS 27.0, iOS 27.0, *) | |
| private actor FakeAudioIngestionService: AudioIngestionServicing { | |
| private(set) var callCount = 0 | |
| private let jobID = AudioIngestionJobID() | |
| func startAudioIngestion( | |
| _ request: AudioIngestionRequest | |
| ) async throws -> AudioIngestionSnapshot { | |
| callCount += 1 | |
| return makeSnapshot(state: .accepted, sourceName: request.source.displayName) | |
| } | |
| func audioIngestionSnapshot( | |
| jobID: AudioIngestionJobID | |
| ) async throws -> AudioIngestionSnapshot { | |
| callCount += 1 | |
| return makeSnapshot(state: .analyzing, sourceName: "fixture.wav") | |
| } | |
| func cancelAudioIngestion( | |
| jobID: AudioIngestionJobID | |
| ) async throws -> AudioIngestionSnapshot { | |
| callCount += 1 | |
| return makeSnapshot(state: .cancelled, sourceName: "fixture.wav") | |
| } | |
| private func makeSnapshot( | |
| state: AudioIngestionState, | |
| sourceName: String | |
| ) -> AudioIngestionSnapshot { | |
| let record = AudioIngestionJobRecord( | |
| id: jobID, | |
| clientRequestID: UUID(), | |
| sourceContentHash: "source-hash", | |
| state: state | |
| ) | |
| let progress = AudioIngestionProgress( | |
| jobID: jobID, | |
| state: state, | |
| sourceName: sourceName, | |
| message: state.rawValue | |
| ) | |
| let widget = AudioIngestionWidgetModel( | |
| jobID: jobID, | |
| title: "Fixture", | |
| sourceName: sourceName, | |
| state: state, | |
| phaseMessage: state.rawValue | |
| ) | |
| return AudioIngestionSnapshot( | |
| record: record, | |
| progress: progress, | |
| widget: widget | |
| ) | |
| } | |
| } | |
Xet Storage Details
- Size:
- 4.24 kB
- Xet hash:
- b0e5350c9f1c0f23a16830db216273910a471e493892420bbb1e6ff3e9d1c319
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.