Sync migrated iOS modules

This commit is contained in:
2026-06-22 15:35:12 +08:00
parent ace9c94359
commit 484566d27e
48 changed files with 4455 additions and 15 deletions

View File

@ -0,0 +1,35 @@
//
// TestFixture.swift
// suixinkanTests
//
// Created by Codex on 2026/6/22.
//
import Foundation
@testable import suixinkan
/// Fixture JSON
enum TestFixture {
/// JSON fixture
static func data(named name: String, filePath: String = #filePath) throws -> Data {
let url = URL(fileURLWithPath: filePath)
.deletingLastPathComponent()
.appendingPathComponent("Fixtures")
.appendingPathComponent("\(name).json")
return try Data(contentsOf: url)
}
/// Envelope
static func payload<T: Decodable>(_ type: T.Type, named name: String) throws -> T {
let envelope = try JSONDecoder().decode(APIEnvelope<T>.self, from: data(named: name))
guard let payload = envelope.data else {
throw FixtureError.emptyPayload
}
return payload
}
}
/// Fixture
enum FixtureError: Error {
case emptyPayload
}