Initial commit: suixinkan_ios UIKit rewrite project.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
68
suixinkan_iosTests/TestFixture.swift
Normal file
68
suixinkan_iosTests/TestFixture.swift
Normal file
@ -0,0 +1,68 @@
|
||||
//
|
||||
// TestFixture.swift
|
||||
// suixinkanTests
|
||||
//
|
||||
// Created by Codex on 2026/6/22.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
@testable import suixinkan_ios
|
||||
|
||||
/// 测试 Fixture 读取工具,用于复用旧工程迁移过来的 JSON 响应。
|
||||
enum TestFixture {
|
||||
/// 读取指定名称的 JSON fixture。
|
||||
static func data(named name: String, filePath: String = #filePath) throws -> Data {
|
||||
var directory = URL(fileURLWithPath: filePath).deletingLastPathComponent()
|
||||
while directory.path != "/" {
|
||||
let url = directory
|
||||
.appendingPathComponent("Fixtures")
|
||||
.appendingPathComponent("\(name).json")
|
||||
if FileManager.default.fileExists(atPath: url.path) {
|
||||
return try Data(contentsOf: url)
|
||||
}
|
||||
directory.deleteLastPathComponent()
|
||||
}
|
||||
let fallback = URL(fileURLWithPath: filePath)
|
||||
.deletingLastPathComponent()
|
||||
.appendingPathComponent("Fixtures")
|
||||
.appendingPathComponent("\(name).json")
|
||||
return try Data(contentsOf: fallback)
|
||||
}
|
||||
|
||||
/// 读取并解包后端统一 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
|
||||
}
|
||||
|
||||
extension OSSUploadServing {
|
||||
/// 旧上传替身默认不关心直播相册入口;Live 专用测试会覆盖此方法记录调用。
|
||||
func uploadAliveAlbumFile(
|
||||
data: Data,
|
||||
fileName: String,
|
||||
fileType: Int,
|
||||
scenicId: Int,
|
||||
onProgress: @escaping (Int) -> Void
|
||||
) async throws -> String {
|
||||
""
|
||||
}
|
||||
|
||||
/// 旧上传替身默认不关心飞手认证入口;飞手认证专用测试会覆盖此方法记录调用。
|
||||
func uploadPilotCertificateImage(
|
||||
data: Data,
|
||||
fileName: String,
|
||||
scenicId: Int,
|
||||
onProgress: @escaping (Int) -> Void
|
||||
) async throws -> String {
|
||||
""
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user