f512d94c74
git-subtree-dir: clients/ds-app git-subtree-mainline:a24e3e6f22git-subtree-split:5206cf3b0c
27 lines
1.2 KiB
Swift
27 lines
1.2 KiB
Swift
// FixtureSupport.swift — canonical fixture 로더 (contract/fixtures/ 를 #filePath 기준으로 직접 읽음).
|
|
//
|
|
// 픽스처는 repo 루트의 `contract/fixtures/` 에 단일 소유(S1 ask.json 등 + S2 가 추가하는
|
|
// foundationmodels-respond / llm-router-chat). 테스트 타깃 안에 복제하면 드리프트가 생기므로
|
|
// 복제 대신 #filePath 에서 repo 루트를 계산해 canonical 파일을 직접 로드한다.
|
|
import Foundation
|
|
|
|
enum Fixture {
|
|
/// repo 루트(.../ds-app-s2) — 이 파일은 <root>/Tests/AITests/FixtureSupport.swift.
|
|
static let repoRoot: URL = URL(fileURLWithPath: #filePath)
|
|
.deletingLastPathComponent() // Tests/AITests
|
|
.deletingLastPathComponent() // Tests
|
|
.deletingLastPathComponent() // <root>
|
|
|
|
static func url(_ name: String) -> URL {
|
|
repoRoot.appendingPathComponent("contract/fixtures").appendingPathComponent(name)
|
|
}
|
|
|
|
static func data(_ name: String) throws -> Data {
|
|
try Data(contentsOf: url(name))
|
|
}
|
|
|
|
static func decode<T: Decodable>(_ type: T.Type, from name: String, using decoder: JSONDecoder = JSONDecoder()) throws -> T {
|
|
try decoder.decode(type, from: data(name))
|
|
}
|
|
}
|