native macOS codings agent orchestrator prowl.onev.cat
Something went wrong. Try again.
2.4 kB · 65 lines
Swift
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566import Foundationimport ProwlCLISharedimport Testing
@testable import supacode
@MainActorstruct CLIProfilesCommandHandlerTests { @Test func listPreservesOrderAndMapsShellProbeAvailability() async throws { let available = AgentProfile(name: "Reviewer", runtime: .claude) let unavailable = AgentProfile(name: "Builder", isEnabled: false, runtime: .codex) let unknown = AgentProfile(name: "Researcher", runtime: .amp) let checkedAt = Date(timeIntervalSince1970: 1_787_390_000) let handler = ProfilesCommandHandler { ProfilesRuntimeSnapshot( profiles: [available, unavailable, unknown], probeResults: [ .claude: AgentRuntimeAvailabilityProbeResult(isAvailable: true, checkedAt: checkedAt), .codex: AgentRuntimeAvailabilityProbeResult(isAvailable: false, checkedAt: checkedAt), ] ) }
let response = await handler.handle( envelope: CommandEnvelope(output: .json, command: .profiles(ProfilesInput())) )
#expect(response.ok) #expect(response.schemaVersion == "prowl.cli.profiles.v1") let data = try #require(response.data) let payload = try data.decode(as: ProfilesCommandPayload.self) #expect(payload.count == 3) #expect(payload.profiles.map(\.id) == [available.id, unavailable.id, unknown.id].map(\.uuidString)) #expect(payload.profiles.map(\.enabled) == [true, false, true]) #expect(payload.profiles.map(\.runtime) == ["claude", "codex", "amp"]) #expect(payload.profiles[0].availability == ProfilesCommandAvailability(status: .available)) #expect( payload.profiles[1].availability == ProfilesCommandAvailability( status: .unavailable, reason: "Codex is not on your shell's PATH" ) ) #expect( payload.profiles[2].availability == ProfilesCommandAvailability( status: .unknown, reason: "Availability check has not completed" ) ) }
@Test func snapshotFailureReturnsProfilesFailed() async { struct SnapshotError: Error {} let handler = ProfilesCommandHandler { throw SnapshotError() }
let response = await handler.handle( envelope: CommandEnvelope(output: .json, command: .profiles(ProfilesInput())) )
#expect(!response.ok) #expect(response.schemaVersion == "prowl.cli.profiles.v1") #expect(response.error?.code == CLIErrorCode.profilesFailed) }}