Files

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))
}
}