| import Testing | |
| @testable import OpenClaw | |
| (.serialized) struct GatewayConnectionIssueTests { | |
| func detectsTokenMissing() { | |
| let issue = GatewayConnectionIssue.detect(from: "unauthorized: gateway token missing") | |
| #expect(issue == .tokenMissing) | |
| #expect(issue.needsAuthToken) | |
| } | |
| func detectsUnauthorized() { | |
| let issue = GatewayConnectionIssue.detect(from: "Gateway error: unauthorized role") | |
| #expect(issue == .unauthorized) | |
| #expect(issue.needsAuthToken) | |
| } | |
| func detectsPairingWithRequestId() { | |
| let issue = GatewayConnectionIssue.detect(from: "pairing required (requestId: abc123)") | |
| #expect(issue == .pairingRequired(requestId: "abc123")) | |
| #expect(issue.needsPairing) | |
| #expect(issue.requestId == "abc123") | |
| } | |
| func detectsNetworkError() { | |
| let issue = GatewayConnectionIssue.detect(from: "Gateway error: Connection refused") | |
| #expect(issue == .network) | |
| } | |
| func returnsNoneForBenignStatus() { | |
| let issue = GatewayConnectionIssue.detect(from: "Connected") | |
| #expect(issue == .none) | |
| } | |
| } | |