localhost1978's picture
download
raw
5.16 kB
import Foundation
import Testing
@testable import SSK_DocGen
@Suite("P0-0 Contract")
struct P0ZeroContractTests {
private let workingDirectory = URL(fileURLWithPath: "/fixtures/workspace", isDirectory: true)
@Test("Generate requires a vault and defaults to incremental mode")
func generateConfiguration() throws {
do {
_ = try SSKDocGenConfiguration.parse(
arguments: ["SSK_DocGen", "generate"],
currentDirectory: workingDirectory
)
Issue.record("generate without --vault must fail")
} catch let error as SSKDocGenCLIError {
#expect(error == .vaultRequired)
}
let configuration = try SSKDocGenConfiguration.parse(
arguments: ["SSK_DocGen", "generate", "--vault", "vault", "--workspace", "source"],
currentDirectory: workingDirectory
)
#expect(configuration.command == .generate)
#expect(configuration.vaultURL?.path == "/fixtures/workspace/vault")
#expect(configuration.workspaceURL.path == "/fixtures/workspace/source")
#expect(configuration.clean == false)
}
@Test("Clean options are explicit and exclusive")
func cleanConfiguration() throws {
let clean = try SSKDocGenConfiguration.parse(
arguments: ["SSK_DocGen", "generate", "--vault", "vault", "--clean"],
currentDirectory: workingDirectory
)
#expect(clean.clean)
let incremental = try SSKDocGenConfiguration.parse(
arguments: ["SSK_DocGen", "generate", "--vault", "vault", "--no-clean"],
currentDirectory: workingDirectory
)
#expect(incremental.clean == false)
do {
_ = try SSKDocGenConfiguration.parse(
arguments: ["SSK_DocGen", "generate", "--vault", "vault", "--clean", "--no-clean"],
currentDirectory: workingDirectory
)
Issue.record("conflicting clean options must fail")
} catch let error as SSKDocGenCLIError {
#expect(error == .conflictingCleanOptions)
}
}
@Test("Error conditions are handled correctly")
func cliErrorConditions() throws {
#expect(throws: SSKDocGenCLIError.missingCommand) {
_ = try SSKDocGenConfiguration.parse(arguments: ["SSK_DocGen"], currentDirectory: workingDirectory)
}
#expect(throws: SSKDocGenCLIError.unsupportedCommand("invalid")) {
_ = try SSKDocGenConfiguration.parse(arguments: ["SSK_DocGen", "invalid"], currentDirectory: workingDirectory)
}
#expect(throws: SSKDocGenCLIError.missingValue("--vault")) {
_ = try SSKDocGenConfiguration.parse(arguments: ["SSK_DocGen", "generate", "--vault"], currentDirectory: workingDirectory)
}
#expect(throws: SSKDocGenCLIError.unknownOption("--invalid-flag")) {
_ = try SSKDocGenConfiguration.parse(arguments: ["SSK_DocGen", "generate", "--vault", "vault", "--invalid-flag"], currentDirectory: workingDirectory)
}
#expect(throws: SSKDocGenCLIError.duplicateOption("--vault")) {
_ = try SSKDocGenConfiguration.parse(arguments: ["SSK_DocGen", "generate", "--vault", "vault1", "--vault", "vault2"], currentDirectory: workingDirectory)
}
#expect(throws: SSKDocGenCLIError.unexpectedArgument("extra")) {
_ = try SSKDocGenConfiguration.parse(arguments: ["SSK_DocGen", "generate", "--vault", "vault", "extra"], currentDirectory: workingDirectory)
}
}
@Test("Registry contains the current ACP contract and bindings")
func currentRegistry() {
let registry = ACPRegistry.current
#expect(registry.methods.count == 10)
#expect(registry.method(named: "tools/call")?.handler == .toolsCall)
#expect(registry.method(named: "call_tool")?.handler == .toolsCall)
#expect(registry.method(named: "prompts/get")?.handler == .synthesize)
#expect(registry.tools.count == 5)
#expect(registry.tool(named: "generate_docs")?.handler == .generateDocs)
#expect(registry.tool(named: "synthesize_media")?.handler == .synthesizeMedia)
#expect(registry.prompts.count == 3)
#expect(registry.resources.count == 4)
#expect(registry.resource(uri: "file:///SSK_Ledger_Vault/graph.json")?.handler == .codebaseGraph)
#expect(registry.resource(uri: "file:///SSK_Ledger_Vault/refresh_status.json")?.handler == .refreshStatus)
}
@Test("Registry accepts a later method registration once")
func registryRegistration() throws {
var registry = try ACPRegistry()
let entry = ACPMethodRegistration(name: "test/method", handler: .initialize)
try registry.register(entry)
#expect(registry.method(named: entry.name) == entry)
do {
try registry.register(entry)
Issue.record("duplicate method registrations must fail")
} catch let error as ACPRegistryRegistrationError {
#expect(error == .duplicateMethod(entry.name))
}
}
}

Xet Storage Details

Size:
5.16 kB
·
Xet hash:
b9aa8b097e9c4e0c5301274b8a3de7ed2031bde5a2b352572ed7358944967d1c

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.