mirror of
https://github.com/hanzoai/bot.git
synced 2026-10-30 17:24:26 +00:00
Comprehensive rename of all openclaw references to hanzo-bot equivalents: - Package: openclaw → @hanzo/bot - Binary: openclaw → hanzo-bot - Types: OpenClaw* → Bot* - Env vars: OPENCLAW_* → BOT_* - Android: ai.openclaw.android → ai.hanzo.bot.android - iOS/macOS: ai.openclaw.* → ai.hanzo.* - Swift modules: OpenClaw* → Bot* - Plugins: openclaw.plugin.json → bot.plugin.json - Paths: .openclaw/ → .hanzo/bot/ - URLs: github.com/openclaw → github.com/hanzoai
68 lines
1.9 KiB
Swift
68 lines
1.9 KiB
Swift
import Foundation
|
|
import Testing
|
|
@testable import HanzoBot
|
|
|
|
@Suite struct WebChatMainSessionKeyTests {
|
|
@Test func configGetSnapshotMainKeyFallsBackToMainWhenMissing() throws {
|
|
let json = """
|
|
{
|
|
"path": "/Users/pete/.hanzo-bot/hanzo-bot.json",
|
|
"exists": true,
|
|
"raw": null,
|
|
"parsed": {},
|
|
"valid": true,
|
|
"config": {},
|
|
"issues": []
|
|
}
|
|
"""
|
|
let key = try GatewayConnection.mainSessionKey(fromConfigGetData: Data(json.utf8))
|
|
#expect(key == "main")
|
|
}
|
|
|
|
@Test func configGetSnapshotMainKeyTrimsAndUsesValue() throws {
|
|
let json = """
|
|
{
|
|
"path": "/Users/pete/.hanzo-bot/hanzo-bot.json",
|
|
"exists": true,
|
|
"raw": null,
|
|
"parsed": {},
|
|
"valid": true,
|
|
"config": { "session": { "mainKey": " primary " } },
|
|
"issues": []
|
|
}
|
|
"""
|
|
let key = try GatewayConnection.mainSessionKey(fromConfigGetData: Data(json.utf8))
|
|
#expect(key == "main")
|
|
}
|
|
|
|
@Test func configGetSnapshotMainKeyFallsBackWhenEmptyOrWhitespace() throws {
|
|
let json = """
|
|
{
|
|
"config": { "session": { "mainKey": " " } }
|
|
}
|
|
"""
|
|
let key = try GatewayConnection.mainSessionKey(fromConfigGetData: Data(json.utf8))
|
|
#expect(key == "main")
|
|
}
|
|
|
|
@Test func configGetSnapshotMainKeyFallsBackWhenConfigNull() throws {
|
|
let json = """
|
|
{
|
|
"config": null
|
|
}
|
|
"""
|
|
let key = try GatewayConnection.mainSessionKey(fromConfigGetData: Data(json.utf8))
|
|
#expect(key == "main")
|
|
}
|
|
|
|
@Test func configGetSnapshotUsesGlobalScope() throws {
|
|
let json = """
|
|
{
|
|
"config": { "session": { "scope": "global" } }
|
|
}
|
|
"""
|
|
let key = try GatewayConnection.mainSessionKey(fromConfigGetData: Data(json.utf8))
|
|
#expect(key == "global")
|
|
}
|
|
}
|