mirror of
https://github.com/openclaw/openclaw.git
synced 2026-02-19 18:39:20 -05:00
Merged via /review-pr -> /prepare-pr -> /merge-pr.
Prepared head SHA: a87eadea19
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Reviewed-by: @mbelinky
34 lines
1.1 KiB
Swift
34 lines
1.1 KiB
Swift
import Testing
|
|
@testable import OpenClaw
|
|
|
|
@Suite(.serialized) struct GatewayConnectionIssueTests {
|
|
@Test func detectsTokenMissing() {
|
|
let issue = GatewayConnectionIssue.detect(from: "unauthorized: gateway token missing")
|
|
#expect(issue == .tokenMissing)
|
|
#expect(issue.needsAuthToken)
|
|
}
|
|
|
|
@Test func detectsUnauthorized() {
|
|
let issue = GatewayConnectionIssue.detect(from: "Gateway error: unauthorized role")
|
|
#expect(issue == .unauthorized)
|
|
#expect(issue.needsAuthToken)
|
|
}
|
|
|
|
@Test func detectsPairingWithRequestId() {
|
|
let issue = GatewayConnectionIssue.detect(from: "pairing required (requestId: abc123)")
|
|
#expect(issue == .pairingRequired(requestId: "abc123"))
|
|
#expect(issue.needsPairing)
|
|
#expect(issue.requestId == "abc123")
|
|
}
|
|
|
|
@Test func detectsNetworkError() {
|
|
let issue = GatewayConnectionIssue.detect(from: "Gateway error: Connection refused")
|
|
#expect(issue == .network)
|
|
}
|
|
|
|
@Test func returnsNoneForBenignStatus() {
|
|
let issue = GatewayConnectionIssue.detect(from: "Connected")
|
|
#expect(issue == .none)
|
|
}
|
|
}
|