Files
openclaw/apps/ios/Tests/GatewayEndpointIDTests.swift

34 lines
1.2 KiB
Swift
Raw Normal View History

2026-01-30 03:15:10 +01:00
import OpenClawKit
2025-12-14 02:05:50 +00:00
import Network
import Testing
2026-01-30 03:15:10 +01:00
@testable import OpenClaw
2025-12-14 02:05:50 +00:00
@Suite struct GatewayEndpointIDTests {
2025-12-14 02:05:50 +00:00
@Test func stableIDForServiceDecodesAndNormalizesName() {
let endpoint = NWEndpoint.service(
2026-01-30 03:15:10 +01:00
name: "OpenClaw\\032Gateway \\032 Node\n",
type: "_openclaw-gw._tcp",
2025-12-14 02:05:50 +00:00
domain: "local.",
interface: nil)
2026-01-30 03:15:10 +01:00
#expect(GatewayEndpointID.stableID(endpoint) == "_openclaw-gw._tcp|local.|OpenClaw Gateway Node")
2025-12-14 02:05:50 +00:00
}
@Test func stableIDForNonServiceUsesEndpointDescription() {
let endpoint = NWEndpoint.hostPort(host: NWEndpoint.Host("127.0.0.1"), port: 4242)
#expect(GatewayEndpointID.stableID(endpoint) == String(describing: endpoint))
2025-12-14 02:05:50 +00:00
}
@Test func prettyDescriptionDecodesBonjourEscapes() {
let endpoint = NWEndpoint.service(
2026-01-30 03:15:10 +01:00
name: "OpenClaw\\032Gateway",
type: "_openclaw-gw._tcp",
2025-12-14 02:05:50 +00:00
domain: "local.",
interface: nil)
let pretty = GatewayEndpointID.prettyDescription(endpoint)
2025-12-14 02:05:50 +00:00
#expect(pretty == BonjourEscapes.decode(String(describing: endpoint)))
#expect(!pretty.localizedCaseInsensitiveContains("\\032"))
}
}