mirror of
https://github.com/hanzoai/bot.git
synced 2026-10-30 17:24:26 +00:00
Automated rebrand of all openclaw references to hanzo bot: - Package: openclaw -> @hanzo/bot - Binary: openclaw -> hanzo-bot - Config: ~/.openclaw -> ~/.hanzo/bot - Docker: ghcr.io/hanzoai/bot - Env vars: OPENCLAW_* -> BOT_* - Bundle IDs: ai.hanzo.bot.* - Product name: Hanzo Bot
55 lines
1.5 KiB
Swift
55 lines
1.5 KiB
Swift
import Testing
|
|
@testable import Hanzo BotChatUI
|
|
|
|
@Suite("ToolResultTextFormatter")
|
|
struct ToolResultTextFormatterTests {
|
|
@Test func leavesPlainTextUntouched() {
|
|
let result = ToolResultTextFormatter.format(text: "All good", toolName: "nodes")
|
|
#expect(result == "All good")
|
|
}
|
|
|
|
@Test func summarizesNodesListJSON() {
|
|
let json = """
|
|
{
|
|
"ts": 1771610031380,
|
|
"nodes": [
|
|
{
|
|
"displayName": "iPhone 16 Pro Max",
|
|
"connected": true,
|
|
"platform": "ios"
|
|
}
|
|
]
|
|
}
|
|
"""
|
|
|
|
let result = ToolResultTextFormatter.format(text: json, toolName: "nodes")
|
|
#expect(result.contains("1 node found."))
|
|
#expect(result.contains("iPhone 16 Pro Max"))
|
|
#expect(result.contains("connected"))
|
|
}
|
|
|
|
@Test func summarizesErrorJSONAndDropsAgentPrefix() {
|
|
let json = """
|
|
{
|
|
"status": "error",
|
|
"tool": "nodes",
|
|
"error": "agent=main node=iPhone gateway=default action=invoke: pairing required"
|
|
}
|
|
"""
|
|
|
|
let result = ToolResultTextFormatter.format(text: json, toolName: "nodes")
|
|
#expect(result == "Error: pairing required")
|
|
}
|
|
|
|
@Test func suppressesUnknownStructuredPayload() {
|
|
let json = """
|
|
{
|
|
"foo": "bar"
|
|
}
|
|
"""
|
|
|
|
let result = ToolResultTextFormatter.format(text: json, toolName: "nodes")
|
|
#expect(result.isEmpty)
|
|
}
|
|
}
|