mirror of
https://github.com/farcasclaudiu/openclaw.git
synced 2026-06-29 09:02:02 +03:00
refactor: rename to openclaw
This commit is contained in:
@@ -1,79 +0,0 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
|
||||
@Suite(.serialized)
|
||||
struct MoltbotConfigFileTests {
|
||||
@Test
|
||||
func configPathRespectsEnvOverride() async {
|
||||
let override = FileManager().temporaryDirectory
|
||||
.appendingPathComponent("moltbot-config-\(UUID().uuidString)")
|
||||
.appendingPathComponent("moltbot.json")
|
||||
.path
|
||||
|
||||
await TestIsolation.withEnvValues(["CLAWDBOT_CONFIG_PATH": override]) {
|
||||
#expect(MoltbotConfigFile.url().path == override)
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Test
|
||||
func remoteGatewayPortParsesAndMatchesHost() async {
|
||||
let override = FileManager().temporaryDirectory
|
||||
.appendingPathComponent("moltbot-config-\(UUID().uuidString)")
|
||||
.appendingPathComponent("moltbot.json")
|
||||
.path
|
||||
|
||||
await TestIsolation.withEnvValues(["CLAWDBOT_CONFIG_PATH": override]) {
|
||||
MoltbotConfigFile.saveDict([
|
||||
"gateway": [
|
||||
"remote": [
|
||||
"url": "ws://gateway.ts.net:19999",
|
||||
],
|
||||
],
|
||||
])
|
||||
#expect(MoltbotConfigFile.remoteGatewayPort() == 19999)
|
||||
#expect(MoltbotConfigFile.remoteGatewayPort(matchingHost: "gateway.ts.net") == 19999)
|
||||
#expect(MoltbotConfigFile.remoteGatewayPort(matchingHost: "gateway") == 19999)
|
||||
#expect(MoltbotConfigFile.remoteGatewayPort(matchingHost: "other.ts.net") == nil)
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Test
|
||||
func setRemoteGatewayUrlPreservesScheme() async {
|
||||
let override = FileManager().temporaryDirectory
|
||||
.appendingPathComponent("moltbot-config-\(UUID().uuidString)")
|
||||
.appendingPathComponent("moltbot.json")
|
||||
.path
|
||||
|
||||
await TestIsolation.withEnvValues(["CLAWDBOT_CONFIG_PATH": override]) {
|
||||
MoltbotConfigFile.saveDict([
|
||||
"gateway": [
|
||||
"remote": [
|
||||
"url": "wss://old-host:111",
|
||||
],
|
||||
],
|
||||
])
|
||||
MoltbotConfigFile.setRemoteGatewayUrl(host: "new-host", port: 2222)
|
||||
let root = MoltbotConfigFile.loadDict()
|
||||
let url = ((root["gateway"] as? [String: Any])?["remote"] as? [String: Any])?["url"] as? String
|
||||
#expect(url == "wss://new-host:2222")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
func stateDirOverrideSetsConfigPath() async {
|
||||
let dir = FileManager().temporaryDirectory
|
||||
.appendingPathComponent("moltbot-state-\(UUID().uuidString)", isDirectory: true)
|
||||
.path
|
||||
|
||||
await TestIsolation.withEnvValues([
|
||||
"CLAWDBOT_CONFIG_PATH": nil,
|
||||
"CLAWDBOT_STATE_DIR": dir,
|
||||
]) {
|
||||
#expect(MoltbotConfigFile.stateDirURL().path == dir)
|
||||
#expect(MoltbotConfigFile.url().path == "\(dir)/moltbot.json")
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
import MoltbotProtocol
|
||||
import OpenClawProtocol
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite
|
||||
@MainActor
|
||||
@@ -16,7 +16,7 @@ struct AgentEventStoreTests {
|
||||
seq: 1,
|
||||
stream: "test",
|
||||
ts: 0,
|
||||
data: [:] as [String: MoltbotProtocol.AnyCodable],
|
||||
data: [:] as [String: OpenClawProtocol.AnyCodable],
|
||||
summary: nil))
|
||||
#expect(store.events.count == 1)
|
||||
|
||||
@@ -33,7 +33,7 @@ struct AgentEventStoreTests {
|
||||
seq: i,
|
||||
stream: "test",
|
||||
ts: Double(i),
|
||||
data: [:] as [String: MoltbotProtocol.AnyCodable],
|
||||
data: [:] as [String: OpenClawProtocol.AnyCodable],
|
||||
summary: nil))
|
||||
}
|
||||
|
||||
+6
-6
@@ -1,6 +1,6 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite
|
||||
struct AgentWorkspaceTests {
|
||||
@@ -29,7 +29,7 @@ struct AgentWorkspaceTests {
|
||||
@Test
|
||||
func bootstrapCreatesAgentsFileWhenMissing() throws {
|
||||
let tmp = FileManager().temporaryDirectory
|
||||
.appendingPathComponent("moltbot-ws-\(UUID().uuidString)", isDirectory: true)
|
||||
.appendingPathComponent("openclaw-ws-\(UUID().uuidString)", isDirectory: true)
|
||||
defer { try? FileManager().removeItem(at: tmp) }
|
||||
|
||||
let agentsURL = try AgentWorkspace.bootstrap(workspaceURL: tmp)
|
||||
@@ -52,7 +52,7 @@ struct AgentWorkspaceTests {
|
||||
@Test
|
||||
func bootstrapSafetyRejectsNonEmptyFolderWithoutAgents() throws {
|
||||
let tmp = FileManager().temporaryDirectory
|
||||
.appendingPathComponent("moltbot-ws-\(UUID().uuidString)", isDirectory: true)
|
||||
.appendingPathComponent("openclaw-ws-\(UUID().uuidString)", isDirectory: true)
|
||||
defer { try? FileManager().removeItem(at: tmp) }
|
||||
try FileManager().createDirectory(at: tmp, withIntermediateDirectories: true)
|
||||
let marker = tmp.appendingPathComponent("notes.txt")
|
||||
@@ -70,7 +70,7 @@ struct AgentWorkspaceTests {
|
||||
@Test
|
||||
func bootstrapSafetyAllowsExistingAgentsFile() throws {
|
||||
let tmp = FileManager().temporaryDirectory
|
||||
.appendingPathComponent("moltbot-ws-\(UUID().uuidString)", isDirectory: true)
|
||||
.appendingPathComponent("openclaw-ws-\(UUID().uuidString)", isDirectory: true)
|
||||
defer { try? FileManager().removeItem(at: tmp) }
|
||||
try FileManager().createDirectory(at: tmp, withIntermediateDirectories: true)
|
||||
let agents = tmp.appendingPathComponent(AgentWorkspace.agentsFilename)
|
||||
@@ -88,7 +88,7 @@ struct AgentWorkspaceTests {
|
||||
@Test
|
||||
func bootstrapSkipsBootstrapFileWhenWorkspaceHasContent() throws {
|
||||
let tmp = FileManager().temporaryDirectory
|
||||
.appendingPathComponent("moltbot-ws-\(UUID().uuidString)", isDirectory: true)
|
||||
.appendingPathComponent("openclaw-ws-\(UUID().uuidString)", isDirectory: true)
|
||||
defer { try? FileManager().removeItem(at: tmp) }
|
||||
try FileManager().createDirectory(at: tmp, withIntermediateDirectories: true)
|
||||
let marker = tmp.appendingPathComponent("notes.txt")
|
||||
@@ -103,7 +103,7 @@ struct AgentWorkspaceTests {
|
||||
@Test
|
||||
func needsBootstrapFalseWhenIdentityAlreadySet() throws {
|
||||
let tmp = FileManager().temporaryDirectory
|
||||
.appendingPathComponent("moltbot-ws-\(UUID().uuidString)", isDirectory: true)
|
||||
.appendingPathComponent("openclaw-ws-\(UUID().uuidString)", isDirectory: true)
|
||||
defer { try? FileManager().removeItem(at: tmp) }
|
||||
try FileManager().createDirectory(at: tmp, withIntermediateDirectories: true)
|
||||
let identityURL = tmp.appendingPathComponent(AgentWorkspace.identityFilename)
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized)
|
||||
@MainActor
|
||||
+3
-3
@@ -1,13 +1,13 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite
|
||||
struct AnthropicAuthResolverTests {
|
||||
@Test
|
||||
func prefersOAuthFileOverEnv() throws {
|
||||
let dir = FileManager().temporaryDirectory
|
||||
.appendingPathComponent("moltbot-oauth-\(UUID().uuidString)", isDirectory: true)
|
||||
.appendingPathComponent("openclaw-oauth-\(UUID().uuidString)", isDirectory: true)
|
||||
try FileManager().createDirectory(at: dir, withIntermediateDirectories: true)
|
||||
let oauthFile = dir.appendingPathComponent("oauth.json")
|
||||
let payload = [
|
||||
@@ -21,7 +21,7 @@ struct AnthropicAuthResolverTests {
|
||||
let data = try JSONSerialization.data(withJSONObject: payload, options: [.prettyPrinted, .sortedKeys])
|
||||
try data.write(to: oauthFile, options: [.atomic])
|
||||
|
||||
let status = MoltbotOAuthStore.anthropicOAuthStatus(at: oauthFile)
|
||||
let status = OpenClawOAuthStore.anthropicOAuthStatus(at: oauthFile)
|
||||
let mode = AnthropicAuthResolver.resolve(environment: [
|
||||
"ANTHROPIC_API_KEY": "sk-ant-ignored",
|
||||
], oauthStatus: status)
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite
|
||||
struct AnthropicOAuthCodeStateTests {
|
||||
+4
-4
@@ -1,8 +1,8 @@
|
||||
import MoltbotProtocol
|
||||
import OpenClawProtocol
|
||||
import Foundation
|
||||
import Testing
|
||||
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite struct AnyCodableEncodingTests {
|
||||
@Test func encodesSwiftArrayAndDictionaryValues() throws {
|
||||
@@ -12,7 +12,7 @@ import Testing
|
||||
"null": NSNull(),
|
||||
]
|
||||
|
||||
let data = try JSONEncoder().encode(MoltbotProtocol.AnyCodable(payload))
|
||||
let data = try JSONEncoder().encode(OpenClawProtocol.AnyCodable(payload))
|
||||
let obj = try #require(JSONSerialization.jsonObject(with: data) as? [String: Any])
|
||||
|
||||
#expect(obj["tags"] as? [String] == ["node", "ios"])
|
||||
@@ -25,7 +25,7 @@ import Testing
|
||||
"items": [1, "two", NSNull(), ["ok": true]],
|
||||
]
|
||||
|
||||
let data = try JSONEncoder().encode(MoltbotProtocol.AnyCodable(payload))
|
||||
let data = try JSONEncoder().encode(OpenClawProtocol.AnyCodable(payload))
|
||||
let obj = try #require(JSONSerialization.jsonObject(with: data) as? [String: Any])
|
||||
|
||||
let items = try #require(obj["items"] as? [Any])
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized)
|
||||
@MainActor
|
||||
@@ -8,12 +8,12 @@ struct CLIInstallerTests {
|
||||
@Test func installedLocationFindsExecutable() throws {
|
||||
let fm = FileManager()
|
||||
let root = fm.temporaryDirectory.appendingPathComponent(
|
||||
"moltbot-cli-installer-\(UUID().uuidString)")
|
||||
"openclaw-cli-installer-\(UUID().uuidString)")
|
||||
defer { try? fm.removeItem(at: root) }
|
||||
|
||||
let binDir = root.appendingPathComponent("bin")
|
||||
try fm.createDirectory(at: binDir, withIntermediateDirectories: true)
|
||||
let cli = binDir.appendingPathComponent("moltbot")
|
||||
let cli = binDir.appendingPathComponent("openclaw")
|
||||
fm.createFile(atPath: cli.path, contents: Data())
|
||||
try fm.setAttributes([.posixPermissions: 0o755], ofItemAtPath: cli.path)
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import Testing
|
||||
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite struct CameraCaptureServiceTests {
|
||||
@Test func normalizeSnapDefaults() {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import MoltbotIPC
|
||||
import OpenClawIPC
|
||||
import Foundation
|
||||
import Testing
|
||||
|
||||
+2
-2
@@ -1,12 +1,12 @@
|
||||
import Foundation
|
||||
import os
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized) struct CanvasFileWatcherTests {
|
||||
private func makeTempDir() throws -> URL {
|
||||
let base = URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true)
|
||||
let dir = base.appendingPathComponent("moltbot-canvaswatch-\(UUID().uuidString)", isDirectory: true)
|
||||
let dir = base.appendingPathComponent("openclaw-canvaswatch-\(UUID().uuidString)", isDirectory: true)
|
||||
try FileManager().createDirectory(at: dir, withIntermediateDirectories: true)
|
||||
return dir
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import MoltbotIPC
|
||||
import OpenClawIPC
|
||||
import Foundation
|
||||
import Testing
|
||||
|
||||
+4
-4
@@ -1,15 +1,15 @@
|
||||
import AppKit
|
||||
import MoltbotIPC
|
||||
import OpenClawIPC
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized)
|
||||
@MainActor
|
||||
struct CanvasWindowSmokeTests {
|
||||
@Test func panelControllerShowsAndHides() async throws {
|
||||
let root = FileManager().temporaryDirectory
|
||||
.appendingPathComponent("moltbot-canvas-test-\(UUID().uuidString)")
|
||||
.appendingPathComponent("openclaw-canvas-test-\(UUID().uuidString)")
|
||||
try FileManager().createDirectory(at: root, withIntermediateDirectories: true)
|
||||
defer { try? FileManager().removeItem(at: root) }
|
||||
|
||||
@@ -32,7 +32,7 @@ struct CanvasWindowSmokeTests {
|
||||
|
||||
@Test func windowControllerShowsAndCloses() async throws {
|
||||
let root = FileManager().temporaryDirectory
|
||||
.appendingPathComponent("moltbot-canvas-test-\(UUID().uuidString)")
|
||||
.appendingPathComponent("openclaw-canvas-test-\(UUID().uuidString)")
|
||||
try FileManager().createDirectory(at: root, withIntermediateDirectories: true)
|
||||
defer { try? FileManager().removeItem(at: root) }
|
||||
|
||||
+4
-4
@@ -1,9 +1,9 @@
|
||||
import MoltbotProtocol
|
||||
import OpenClawProtocol
|
||||
import SwiftUI
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
private typealias SnapshotAnyCodable = Moltbot.AnyCodable
|
||||
private typealias SnapshotAnyCodable = OpenClaw.AnyCodable
|
||||
|
||||
@Suite(.serialized)
|
||||
@MainActor
|
||||
@@ -52,7 +52,7 @@ struct ChannelsSettingsSmokeTests {
|
||||
"ok": true,
|
||||
"status": 200,
|
||||
"elapsedMs": 120,
|
||||
"bot": ["id": 123, "username": "moltbotbot"],
|
||||
"bot": ["id": 123, "username": "openclawbot"],
|
||||
"webhook": ["url": "https://example.com/hook", "hasCustomCert": false],
|
||||
],
|
||||
"lastProbeAt": 1_700_000_050_000,
|
||||
+23
-23
@@ -1,7 +1,7 @@
|
||||
import Darwin
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized) struct CommandResolverTests {
|
||||
private func makeDefaults() -> UserDefaults {
|
||||
@@ -24,18 +24,18 @@ import Testing
|
||||
try FileManager().setAttributes([.posixPermissions: 0o755], ofItemAtPath: path.path)
|
||||
}
|
||||
|
||||
@Test func prefersMoltbotBinary() async throws {
|
||||
@Test func prefersOpenClawBinary() async throws {
|
||||
let defaults = self.makeDefaults()
|
||||
defaults.set(AppState.ConnectionMode.local.rawValue, forKey: connectionModeKey)
|
||||
|
||||
let tmp = try makeTempDir()
|
||||
CommandResolver.setProjectRoot(tmp.path)
|
||||
|
||||
let moltbotPath = tmp.appendingPathComponent("node_modules/.bin/moltbot")
|
||||
try self.makeExec(at: moltbotPath)
|
||||
let openclawPath = tmp.appendingPathComponent("node_modules/.bin/openclaw")
|
||||
try self.makeExec(at: openclawPath)
|
||||
|
||||
let cmd = CommandResolver.moltbotCommand(subcommand: "gateway", defaults: defaults, configRoot: [:])
|
||||
#expect(cmd.prefix(2).elementsEqual([moltbotPath.path, "gateway"]))
|
||||
let cmd = CommandResolver.openclawCommand(subcommand: "gateway", defaults: defaults, configRoot: [:])
|
||||
#expect(cmd.prefix(2).elementsEqual([openclawPath.path, "gateway"]))
|
||||
}
|
||||
|
||||
@Test func fallsBackToNodeAndScript() async throws {
|
||||
@@ -46,13 +46,13 @@ import Testing
|
||||
CommandResolver.setProjectRoot(tmp.path)
|
||||
|
||||
let nodePath = tmp.appendingPathComponent("node_modules/.bin/node")
|
||||
let scriptPath = tmp.appendingPathComponent("bin/moltbot.js")
|
||||
let scriptPath = tmp.appendingPathComponent("bin/openclaw.js")
|
||||
try self.makeExec(at: nodePath)
|
||||
try "#!/bin/sh\necho v22.0.0\n".write(to: nodePath, atomically: true, encoding: .utf8)
|
||||
try FileManager().setAttributes([.posixPermissions: 0o755], ofItemAtPath: nodePath.path)
|
||||
try self.makeExec(at: scriptPath)
|
||||
|
||||
let cmd = CommandResolver.moltbotCommand(
|
||||
let cmd = CommandResolver.openclawCommand(
|
||||
subcommand: "rpc",
|
||||
defaults: defaults,
|
||||
configRoot: [:],
|
||||
@@ -76,9 +76,9 @@ import Testing
|
||||
let pnpmPath = tmp.appendingPathComponent("node_modules/.bin/pnpm")
|
||||
try self.makeExec(at: pnpmPath)
|
||||
|
||||
let cmd = CommandResolver.moltbotCommand(subcommand: "rpc", defaults: defaults, configRoot: [:])
|
||||
let cmd = CommandResolver.openclawCommand(subcommand: "rpc", defaults: defaults, configRoot: [:])
|
||||
|
||||
#expect(cmd.prefix(4).elementsEqual([pnpmPath.path, "--silent", "moltbot", "rpc"]))
|
||||
#expect(cmd.prefix(4).elementsEqual([pnpmPath.path, "--silent", "openclaw", "rpc"]))
|
||||
}
|
||||
|
||||
@Test func pnpmKeepsExtraArgsAfterSubcommand() async throws {
|
||||
@@ -91,13 +91,13 @@ import Testing
|
||||
let pnpmPath = tmp.appendingPathComponent("node_modules/.bin/pnpm")
|
||||
try self.makeExec(at: pnpmPath)
|
||||
|
||||
let cmd = CommandResolver.moltbotCommand(
|
||||
let cmd = CommandResolver.openclawCommand(
|
||||
subcommand: "health",
|
||||
extraArgs: ["--json", "--timeout", "5"],
|
||||
defaults: defaults,
|
||||
configRoot: [:])
|
||||
|
||||
#expect(cmd.prefix(5).elementsEqual([pnpmPath.path, "--silent", "moltbot", "health", "--json"]))
|
||||
#expect(cmd.prefix(5).elementsEqual([pnpmPath.path, "--silent", "openclaw", "health", "--json"]))
|
||||
#expect(cmd.suffix(2).elementsEqual(["--timeout", "5"]))
|
||||
}
|
||||
|
||||
@@ -112,11 +112,11 @@ import Testing
|
||||
@Test func buildsSSHCommandForRemoteMode() async throws {
|
||||
let defaults = self.makeDefaults()
|
||||
defaults.set(AppState.ConnectionMode.remote.rawValue, forKey: connectionModeKey)
|
||||
defaults.set("clawd@example.com:2222", forKey: remoteTargetKey)
|
||||
defaults.set("openclaw@example.com:2222", forKey: remoteTargetKey)
|
||||
defaults.set("/tmp/id_ed25519", forKey: remoteIdentityKey)
|
||||
defaults.set("/srv/moltbot", forKey: remoteProjectRootKey)
|
||||
defaults.set("/srv/openclaw", forKey: remoteProjectRootKey)
|
||||
|
||||
let cmd = CommandResolver.moltbotCommand(
|
||||
let cmd = CommandResolver.openclawCommand(
|
||||
subcommand: "status",
|
||||
extraArgs: ["--json"],
|
||||
defaults: defaults,
|
||||
@@ -124,16 +124,16 @@ import Testing
|
||||
|
||||
#expect(cmd.first == "/usr/bin/ssh")
|
||||
if let marker = cmd.firstIndex(of: "--") {
|
||||
#expect(cmd[marker + 1] == "clawd@example.com")
|
||||
#expect(cmd[marker + 1] == "openclaw@example.com")
|
||||
} else {
|
||||
#expect(Bool(false))
|
||||
}
|
||||
#expect(cmd.contains("-i"))
|
||||
#expect(cmd.contains("/tmp/id_ed25519"))
|
||||
if let script = cmd.last {
|
||||
#expect(script.contains("PRJ='/srv/moltbot'"))
|
||||
#expect(script.contains("PRJ='/srv/openclaw'"))
|
||||
#expect(script.contains("cd \"$PRJ\""))
|
||||
#expect(script.contains("moltbot"))
|
||||
#expect(script.contains("openclaw"))
|
||||
#expect(script.contains("status"))
|
||||
#expect(script.contains("--json"))
|
||||
#expect(script.contains("CLI="))
|
||||
@@ -149,20 +149,20 @@ import Testing
|
||||
@Test func configRootLocalOverridesRemoteDefaults() async throws {
|
||||
let defaults = self.makeDefaults()
|
||||
defaults.set(AppState.ConnectionMode.remote.rawValue, forKey: connectionModeKey)
|
||||
defaults.set("clawd@example.com:2222", forKey: remoteTargetKey)
|
||||
defaults.set("openclaw@example.com:2222", forKey: remoteTargetKey)
|
||||
|
||||
let tmp = try makeTempDir()
|
||||
CommandResolver.setProjectRoot(tmp.path)
|
||||
|
||||
let moltbotPath = tmp.appendingPathComponent("node_modules/.bin/moltbot")
|
||||
try self.makeExec(at: moltbotPath)
|
||||
let openclawPath = tmp.appendingPathComponent("node_modules/.bin/openclaw")
|
||||
try self.makeExec(at: openclawPath)
|
||||
|
||||
let cmd = CommandResolver.moltbotCommand(
|
||||
let cmd = CommandResolver.openclawCommand(
|
||||
subcommand: "daemon",
|
||||
defaults: defaults,
|
||||
configRoot: ["gateway": ["mode": "local"]])
|
||||
|
||||
#expect(cmd.first == moltbotPath.path)
|
||||
#expect(cmd.first == openclawPath.path)
|
||||
#expect(cmd.count >= 2)
|
||||
if cmd.count >= 2 {
|
||||
#expect(cmd[1] == "daemon")
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized)
|
||||
@MainActor
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import AppKit
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite
|
||||
@MainActor
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import SwiftUI
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized)
|
||||
@MainActor
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite
|
||||
struct CronModelsTests {
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite
|
||||
struct DeviceModelCatalogTests {
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
struct ExecAllowlistTests {
|
||||
@Test func matchUsesResolvedPath() {
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite struct ExecApprovalHelpersTests {
|
||||
@Test func parseDecisionTrimsAndRejectsInvalid() {
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite
|
||||
@MainActor
|
||||
+1
-1
@@ -5,7 +5,7 @@ import Testing
|
||||
@Test func sourcesAvoidLegacyNonThrowingFileHandleReadAPIs() throws {
|
||||
let testFile = URL(fileURLWithPath: #filePath)
|
||||
let packageRoot = testFile
|
||||
.deletingLastPathComponent() // MoltbotIPCTests
|
||||
.deletingLastPathComponent() // OpenClawIPCTests
|
||||
.deletingLastPathComponent() // Tests
|
||||
.deletingLastPathComponent() // apps/macos
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite struct FileHandleSafeReadTests {
|
||||
@Test func readToEndSafelyReturnsEmptyForClosedHandle() {
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite struct GatewayAgentChannelTests {
|
||||
@Test func shouldDeliverBlocksWebChat() {
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized)
|
||||
struct GatewayAutostartPolicyTests {
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
import MoltbotKit
|
||||
import OpenClawKit
|
||||
import Foundation
|
||||
import os
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite struct GatewayConnectionTests {
|
||||
private final class FakeWebSocketTask: WebSocketTasking, @unchecked Sendable {
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
import MoltbotKit
|
||||
import OpenClawKit
|
||||
import Foundation
|
||||
import os
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite struct GatewayChannelConnectTests {
|
||||
private enum FakeResponse {
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
import MoltbotKit
|
||||
import OpenClawKit
|
||||
import Foundation
|
||||
import os
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite struct GatewayChannelRequestTests {
|
||||
private final class FakeWebSocketTask: WebSocketTasking, @unchecked Sendable {
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
import MoltbotKit
|
||||
import OpenClawKit
|
||||
import Foundation
|
||||
import os
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite struct GatewayChannelShutdownTests {
|
||||
private final class FakeWebSocketTask: WebSocketTasking, @unchecked Sendable {
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
import MoltbotKit
|
||||
import OpenClawKit
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import MoltbotIPC
|
||||
@testable import OpenClaw
|
||||
@testable import OpenClawIPC
|
||||
|
||||
private final class FakeWebSocketTask: WebSocketTasking, @unchecked Sendable {
|
||||
var state: URLSessionTask.State = .running
|
||||
+6
-6
@@ -1,4 +1,4 @@
|
||||
import MoltbotDiscovery
|
||||
import OpenClawDiscovery
|
||||
import Testing
|
||||
|
||||
@Suite
|
||||
@@ -35,7 +35,7 @@ struct GatewayDiscoveryModelTests {
|
||||
#expect(GatewayDiscoveryModel.isLocalGateway(
|
||||
lanHost: nil,
|
||||
tailnetDns: nil,
|
||||
displayName: "Peter's Mac Studio (Moltbot)",
|
||||
displayName: "Peter's Mac Studio (OpenClaw)",
|
||||
serviceName: nil,
|
||||
local: local))
|
||||
}
|
||||
@@ -72,13 +72,13 @@ struct GatewayDiscoveryModelTests {
|
||||
lanHost: nil,
|
||||
tailnetDns: nil,
|
||||
displayName: nil,
|
||||
serviceName: "steipetacstudio (Moltbot)",
|
||||
serviceName: "steipetacstudio (OpenClaw)",
|
||||
local: local))
|
||||
#expect(GatewayDiscoveryModel.isLocalGateway(
|
||||
lanHost: nil,
|
||||
tailnetDns: nil,
|
||||
displayName: nil,
|
||||
serviceName: "steipete (Moltbot)",
|
||||
serviceName: "steipete (OpenClaw)",
|
||||
local: local))
|
||||
}
|
||||
|
||||
@@ -88,13 +88,13 @@ struct GatewayDiscoveryModelTests {
|
||||
"tailnetDns": " peters-mac-studio-1.ts.net ",
|
||||
"sshPort": " 2222 ",
|
||||
"gatewayPort": " 18799 ",
|
||||
"cliPath": " /opt/moltbot ",
|
||||
"cliPath": " /opt/openclaw ",
|
||||
])
|
||||
#expect(parsed.lanHost == "studio.local")
|
||||
#expect(parsed.tailnetDns == "peters-mac-studio-1.ts.net")
|
||||
#expect(parsed.sshPort == 2222)
|
||||
#expect(parsed.gatewayPort == 18799)
|
||||
#expect(parsed.cliPath == "/opt/moltbot")
|
||||
#expect(parsed.cliPath == "/opt/openclaw")
|
||||
}
|
||||
|
||||
@Test func parsesGatewayTXTDefaults() {
|
||||
+5
-5
@@ -1,6 +1,6 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite struct GatewayEndpointStoreTests {
|
||||
private func makeDefaults() -> UserDefaults {
|
||||
@@ -13,7 +13,7 @@ import Testing
|
||||
@Test func resolveGatewayTokenPrefersEnvAndFallsBackToLaunchd() {
|
||||
let snapshot = LaunchAgentPlistSnapshot(
|
||||
programArguments: [],
|
||||
environment: ["CLAWDBOT_GATEWAY_TOKEN": "launchd-token"],
|
||||
environment: ["OPENCLAW_GATEWAY_TOKEN": "launchd-token"],
|
||||
stdoutPath: nil,
|
||||
stderrPath: nil,
|
||||
port: nil,
|
||||
@@ -24,7 +24,7 @@ import Testing
|
||||
let envToken = GatewayEndpointStore._testResolveGatewayToken(
|
||||
isRemote: false,
|
||||
root: [:],
|
||||
env: ["CLAWDBOT_GATEWAY_TOKEN": "env-token"],
|
||||
env: ["OPENCLAW_GATEWAY_TOKEN": "env-token"],
|
||||
launchdSnapshot: snapshot)
|
||||
#expect(envToken == "env-token")
|
||||
|
||||
@@ -39,7 +39,7 @@ import Testing
|
||||
@Test func resolveGatewayTokenIgnoresLaunchdInRemoteMode() {
|
||||
let snapshot = LaunchAgentPlistSnapshot(
|
||||
programArguments: [],
|
||||
environment: ["CLAWDBOT_GATEWAY_TOKEN": "launchd-token"],
|
||||
environment: ["OPENCLAW_GATEWAY_TOKEN": "launchd-token"],
|
||||
stdoutPath: nil,
|
||||
stderrPath: nil,
|
||||
port: nil,
|
||||
@@ -58,7 +58,7 @@ import Testing
|
||||
@Test func resolveGatewayPasswordFallsBackToLaunchd() {
|
||||
let snapshot = LaunchAgentPlistSnapshot(
|
||||
programArguments: [],
|
||||
environment: ["CLAWDBOT_GATEWAY_PASSWORD": "launchd-pass"],
|
||||
environment: ["OPENCLAW_GATEWAY_PASSWORD": "launchd-pass"],
|
||||
stdoutPath: nil,
|
||||
stderrPath: nil,
|
||||
port: nil,
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite struct GatewayEnvironmentTests {
|
||||
@Test func semverParsesCommonForms() {
|
||||
@@ -34,7 +34,7 @@ import Testing
|
||||
@Test func gatewayPortDefaultsAndRespectsOverride() async {
|
||||
let configPath = TestIsolation.tempConfigPath()
|
||||
await TestIsolation.withIsolatedState(
|
||||
env: ["CLAWDBOT_CONFIG_PATH": configPath],
|
||||
env: ["OPENCLAW_CONFIG_PATH": configPath],
|
||||
defaults: ["gatewayPort": nil])
|
||||
{
|
||||
let defaultPort = GatewayEnvironment.gatewayPort()
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import MoltbotProtocol
|
||||
import OpenClawProtocol
|
||||
import Foundation
|
||||
import Testing
|
||||
|
||||
+7
-7
@@ -1,16 +1,16 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite struct GatewayLaunchAgentManagerTests {
|
||||
@Test func launchAgentPlistSnapshotParsesArgsAndEnv() throws {
|
||||
let url = FileManager().temporaryDirectory
|
||||
.appendingPathComponent("moltbot-launchd-\(UUID().uuidString).plist")
|
||||
.appendingPathComponent("openclaw-launchd-\(UUID().uuidString).plist")
|
||||
let plist: [String: Any] = [
|
||||
"ProgramArguments": ["moltbot", "gateway-daemon", "--port", "18789", "--bind", "loopback"],
|
||||
"ProgramArguments": ["openclaw", "gateway-daemon", "--port", "18789", "--bind", "loopback"],
|
||||
"EnvironmentVariables": [
|
||||
"CLAWDBOT_GATEWAY_TOKEN": " secret ",
|
||||
"CLAWDBOT_GATEWAY_PASSWORD": "pw",
|
||||
"OPENCLAW_GATEWAY_TOKEN": " secret ",
|
||||
"OPENCLAW_GATEWAY_PASSWORD": "pw",
|
||||
],
|
||||
]
|
||||
let data = try PropertyListSerialization.data(fromPropertyList: plist, format: .xml, options: 0)
|
||||
@@ -26,9 +26,9 @@ import Testing
|
||||
|
||||
@Test func launchAgentPlistSnapshotAllowsMissingBind() throws {
|
||||
let url = FileManager().temporaryDirectory
|
||||
.appendingPathComponent("moltbot-launchd-\(UUID().uuidString).plist")
|
||||
.appendingPathComponent("openclaw-launchd-\(UUID().uuidString).plist")
|
||||
let plist: [String: Any] = [
|
||||
"ProgramArguments": ["moltbot", "gateway-daemon", "--port", "18789"],
|
||||
"ProgramArguments": ["openclaw", "gateway-daemon", "--port", "18789"],
|
||||
]
|
||||
let data = try PropertyListSerialization.data(fromPropertyList: plist, format: .xml, options: 0)
|
||||
try data.write(to: url, options: [.atomic])
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
import MoltbotKit
|
||||
import OpenClawKit
|
||||
import Foundation
|
||||
import os
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized)
|
||||
@MainActor
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite struct HealthDecodeTests {
|
||||
private let sampleJSON: String = // minimal but complete payload
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite struct HealthStoreStateTests {
|
||||
@Test @MainActor func linkedChannelProbeFailureDegradesState() async throws {
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import AppKit
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized)
|
||||
@MainActor
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized)
|
||||
@MainActor
|
||||
+6
-6
@@ -1,6 +1,6 @@
|
||||
import MoltbotProtocol
|
||||
import OpenClawProtocol
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite struct InstancesStoreTests {
|
||||
@Test
|
||||
@@ -8,7 +8,7 @@ import Testing
|
||||
func presenceEventPayloadDecodesViaJSONEncoder() {
|
||||
// Build a payload that mirrors the gateway's presence event shape:
|
||||
// { "presence": [ PresenceEntry ] }
|
||||
let entry: [String: MoltbotProtocol.AnyCodable] = [
|
||||
let entry: [String: OpenClawProtocol.AnyCodable] = [
|
||||
"host": .init("gw"),
|
||||
"ip": .init("10.0.0.1"),
|
||||
"version": .init("2.0.0"),
|
||||
@@ -18,10 +18,10 @@ import Testing
|
||||
"text": .init("Gateway node"),
|
||||
"ts": .init(1_730_000_000),
|
||||
]
|
||||
let payloadMap: [String: MoltbotProtocol.AnyCodable] = [
|
||||
"presence": .init([MoltbotProtocol.AnyCodable(entry)]),
|
||||
let payloadMap: [String: OpenClawProtocol.AnyCodable] = [
|
||||
"presence": .init([OpenClawProtocol.AnyCodable(entry)]),
|
||||
]
|
||||
let payload = MoltbotProtocol.AnyCodable(payloadMap)
|
||||
let payload = OpenClawProtocol.AnyCodable(payloadMap)
|
||||
|
||||
let store = InstancesStore(isPreview: true)
|
||||
store.handlePresenceEventPayload(payload)
|
||||
+4
-4
@@ -1,17 +1,17 @@
|
||||
import Darwin
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite struct LogLocatorTests {
|
||||
@Test func launchdGatewayLogPathEnsuresTmpDirExists() throws {
|
||||
let fm = FileManager()
|
||||
let baseDir = URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true)
|
||||
let logDir = baseDir.appendingPathComponent("moltbot-tests-\(UUID().uuidString)")
|
||||
let logDir = baseDir.appendingPathComponent("openclaw-tests-\(UUID().uuidString)")
|
||||
|
||||
setenv("CLAWDBOT_LOG_DIR", logDir.path, 1)
|
||||
setenv("OPENCLAW_LOG_DIR", logDir.path, 1)
|
||||
defer {
|
||||
unsetenv("CLAWDBOT_LOG_DIR")
|
||||
unsetenv("OPENCLAW_LOG_DIR")
|
||||
try? fm.removeItem(at: logDir)
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,13 +1,13 @@
|
||||
import AppKit
|
||||
import MoltbotProtocol
|
||||
import OpenClawProtocol
|
||||
import Foundation
|
||||
import Testing
|
||||
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized)
|
||||
struct LowCoverageHelperTests {
|
||||
private typealias ProtoAnyCodable = MoltbotProtocol.AnyCodable
|
||||
private typealias ProtoAnyCodable = OpenClawProtocol.AnyCodable
|
||||
|
||||
@Test func anyCodableHelperAccessors() throws {
|
||||
let payload: [String: ProtoAnyCodable] = [
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
import AppKit
|
||||
import MoltbotProtocol
|
||||
import OpenClawProtocol
|
||||
import SwiftUI
|
||||
import Testing
|
||||
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized)
|
||||
@MainActor
|
||||
+10
-10
@@ -1,13 +1,13 @@
|
||||
import MoltbotChatUI
|
||||
import MoltbotProtocol
|
||||
import OpenClawChatUI
|
||||
import OpenClawProtocol
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite struct MacGatewayChatTransportMappingTests {
|
||||
@Test func snapshotMapsToHealth() {
|
||||
let snapshot = Snapshot(
|
||||
presence: [],
|
||||
health: MoltbotProtocol.AnyCodable(["ok": MoltbotProtocol.AnyCodable(false)]),
|
||||
health: OpenClawProtocol.AnyCodable(["ok": OpenClawProtocol.AnyCodable(false)]),
|
||||
stateversion: StateVersion(presence: 1, health: 1),
|
||||
uptimems: 123,
|
||||
configpath: nil,
|
||||
@@ -37,7 +37,7 @@ import Testing
|
||||
let frame = EventFrame(
|
||||
type: "event",
|
||||
event: "health",
|
||||
payload: MoltbotProtocol.AnyCodable(["ok": MoltbotProtocol.AnyCodable(true)]),
|
||||
payload: OpenClawProtocol.AnyCodable(["ok": OpenClawProtocol.AnyCodable(true)]),
|
||||
seq: 1,
|
||||
stateversion: nil)
|
||||
|
||||
@@ -60,10 +60,10 @@ import Testing
|
||||
}
|
||||
|
||||
@Test func chatEventMapsToChat() {
|
||||
let payload = MoltbotProtocol.AnyCodable([
|
||||
"runId": MoltbotProtocol.AnyCodable("run-1"),
|
||||
"sessionKey": MoltbotProtocol.AnyCodable("main"),
|
||||
"state": MoltbotProtocol.AnyCodable("final"),
|
||||
let payload = OpenClawProtocol.AnyCodable([
|
||||
"runId": OpenClawProtocol.AnyCodable("run-1"),
|
||||
"sessionKey": OpenClawProtocol.AnyCodable("main"),
|
||||
"state": OpenClawProtocol.AnyCodable("final"),
|
||||
])
|
||||
let frame = EventFrame(type: "event", event: "chat", payload: payload, seq: 1, stateversion: nil)
|
||||
let mapped = MacGatewayChatTransport.mapPushToTransportEvent(.event(frame))
|
||||
@@ -82,7 +82,7 @@ import Testing
|
||||
let frame = EventFrame(
|
||||
type: "event",
|
||||
event: "unknown",
|
||||
payload: MoltbotProtocol.AnyCodable(["a": MoltbotProtocol.AnyCodable(1)]),
|
||||
payload: OpenClawProtocol.AnyCodable(["a": OpenClawProtocol.AnyCodable(1)]),
|
||||
seq: 1,
|
||||
stateversion: nil)
|
||||
let mapped = MacGatewayChatTransport.mapPushToTransportEvent(.event(frame))
|
||||
+11
-11
@@ -1,8 +1,8 @@
|
||||
import MoltbotKit
|
||||
import OpenClawKit
|
||||
import CoreLocation
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
struct MacNodeRuntimeTests {
|
||||
@Test func handleInvokeRejectsUnknownCommand() async {
|
||||
@@ -14,28 +14,28 @@ struct MacNodeRuntimeTests {
|
||||
|
||||
@Test func handleInvokeRejectsEmptySystemRun() async throws {
|
||||
let runtime = MacNodeRuntime()
|
||||
let params = MoltbotSystemRunParams(command: [])
|
||||
let params = OpenClawSystemRunParams(command: [])
|
||||
let json = try String(data: JSONEncoder().encode(params), encoding: .utf8)
|
||||
let response = await runtime.handleInvoke(
|
||||
BridgeInvokeRequest(id: "req-2", command: MoltbotSystemCommand.run.rawValue, paramsJSON: json))
|
||||
BridgeInvokeRequest(id: "req-2", command: OpenClawSystemCommand.run.rawValue, paramsJSON: json))
|
||||
#expect(response.ok == false)
|
||||
}
|
||||
|
||||
@Test func handleInvokeRejectsEmptySystemWhich() async throws {
|
||||
let runtime = MacNodeRuntime()
|
||||
let params = MoltbotSystemWhichParams(bins: [])
|
||||
let params = OpenClawSystemWhichParams(bins: [])
|
||||
let json = try String(data: JSONEncoder().encode(params), encoding: .utf8)
|
||||
let response = await runtime.handleInvoke(
|
||||
BridgeInvokeRequest(id: "req-2b", command: MoltbotSystemCommand.which.rawValue, paramsJSON: json))
|
||||
BridgeInvokeRequest(id: "req-2b", command: OpenClawSystemCommand.which.rawValue, paramsJSON: json))
|
||||
#expect(response.ok == false)
|
||||
}
|
||||
|
||||
@Test func handleInvokeRejectsEmptyNotification() async throws {
|
||||
let runtime = MacNodeRuntime()
|
||||
let params = MoltbotSystemNotifyParams(title: "", body: "")
|
||||
let params = OpenClawSystemNotifyParams(title: "", body: "")
|
||||
let json = try String(data: JSONEncoder().encode(params), encoding: .utf8)
|
||||
let response = await runtime.handleInvoke(
|
||||
BridgeInvokeRequest(id: "req-3", command: MoltbotSystemCommand.notify.rawValue, paramsJSON: json))
|
||||
BridgeInvokeRequest(id: "req-3", command: OpenClawSystemCommand.notify.rawValue, paramsJSON: json))
|
||||
#expect(response.ok == false)
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ struct MacNodeRuntimeTests {
|
||||
await TestIsolation.withUserDefaultsValues([cameraEnabledKey: false]) {
|
||||
let runtime = MacNodeRuntime()
|
||||
let response = await runtime.handleInvoke(
|
||||
BridgeInvokeRequest(id: "req-4", command: MoltbotCameraCommand.list.rawValue))
|
||||
BridgeInvokeRequest(id: "req-4", command: OpenClawCameraCommand.list.rawValue))
|
||||
#expect(response.ok == false)
|
||||
#expect(response.error?.message.contains("CAMERA_DISABLED") == true)
|
||||
}
|
||||
@@ -60,7 +60,7 @@ struct MacNodeRuntimeTests {
|
||||
outPath: String?) async throws -> (path: String, hasAudio: Bool)
|
||||
{
|
||||
let url = FileManager().temporaryDirectory
|
||||
.appendingPathComponent("moltbot-test-screen-record-\(UUID().uuidString).mp4")
|
||||
.appendingPathComponent("openclaw-test-screen-record-\(UUID().uuidString).mp4")
|
||||
try Data("ok".utf8).write(to: url)
|
||||
return (path: url.path, hasAudio: false)
|
||||
}
|
||||
@@ -68,7 +68,7 @@ struct MacNodeRuntimeTests {
|
||||
func locationAuthorizationStatus() -> CLAuthorizationStatus { .authorizedAlways }
|
||||
func locationAccuracyAuthorization() -> CLAccuracyAuthorization { .fullAccuracy }
|
||||
func currentLocation(
|
||||
desiredAccuracy: MoltbotLocationAccuracy,
|
||||
desiredAccuracy: OpenClawLocationAccuracy,
|
||||
maxAgeMs: Int?,
|
||||
timeoutMs: Int?) async throws -> CLLocation
|
||||
{
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
import MoltbotDiscovery
|
||||
import OpenClawDiscovery
|
||||
import SwiftUI
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized)
|
||||
@MainActor
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import SwiftUI
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized)
|
||||
@MainActor
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import AppKit
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized)
|
||||
@MainActor
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite
|
||||
struct ModelCatalogLoaderTests {
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite struct NodeManagerPathsTests {
|
||||
private func makeTempDir() throws -> URL {
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized)
|
||||
@MainActor
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite struct NodePairingReconcilePolicyTests {
|
||||
@Test func policyPollsOnlyWhenActive() {
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized)
|
||||
@MainActor
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
import MoltbotDiscovery
|
||||
import OpenClawDiscovery
|
||||
import SwiftUI
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized)
|
||||
@MainActor
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
import MoltbotProtocol
|
||||
import OpenClawProtocol
|
||||
import SwiftUI
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
private typealias ProtoAnyCodable = MoltbotProtocol.AnyCodable
|
||||
private typealias ProtoAnyCodable = OpenClawProtocol.AnyCodable
|
||||
|
||||
@Suite(.serialized)
|
||||
@MainActor
|
||||
@@ -0,0 +1,79 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized)
|
||||
struct OpenClawConfigFileTests {
|
||||
@Test
|
||||
func configPathRespectsEnvOverride() async {
|
||||
let override = FileManager().temporaryDirectory
|
||||
.appendingPathComponent("openclaw-config-\(UUID().uuidString)")
|
||||
.appendingPathComponent("openclaw.json")
|
||||
.path
|
||||
|
||||
await TestIsolation.withEnvValues(["OPENCLAW_CONFIG_PATH": override]) {
|
||||
#expect(OpenClawConfigFile.url().path == override)
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Test
|
||||
func remoteGatewayPortParsesAndMatchesHost() async {
|
||||
let override = FileManager().temporaryDirectory
|
||||
.appendingPathComponent("openclaw-config-\(UUID().uuidString)")
|
||||
.appendingPathComponent("openclaw.json")
|
||||
.path
|
||||
|
||||
await TestIsolation.withEnvValues(["OPENCLAW_CONFIG_PATH": override]) {
|
||||
OpenClawConfigFile.saveDict([
|
||||
"gateway": [
|
||||
"remote": [
|
||||
"url": "ws://gateway.ts.net:19999",
|
||||
],
|
||||
],
|
||||
])
|
||||
#expect(OpenClawConfigFile.remoteGatewayPort() == 19999)
|
||||
#expect(OpenClawConfigFile.remoteGatewayPort(matchingHost: "gateway.ts.net") == 19999)
|
||||
#expect(OpenClawConfigFile.remoteGatewayPort(matchingHost: "gateway") == 19999)
|
||||
#expect(OpenClawConfigFile.remoteGatewayPort(matchingHost: "other.ts.net") == nil)
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Test
|
||||
func setRemoteGatewayUrlPreservesScheme() async {
|
||||
let override = FileManager().temporaryDirectory
|
||||
.appendingPathComponent("openclaw-config-\(UUID().uuidString)")
|
||||
.appendingPathComponent("openclaw.json")
|
||||
.path
|
||||
|
||||
await TestIsolation.withEnvValues(["OPENCLAW_CONFIG_PATH": override]) {
|
||||
OpenClawConfigFile.saveDict([
|
||||
"gateway": [
|
||||
"remote": [
|
||||
"url": "wss://old-host:111",
|
||||
],
|
||||
],
|
||||
])
|
||||
OpenClawConfigFile.setRemoteGatewayUrl(host: "new-host", port: 2222)
|
||||
let root = OpenClawConfigFile.loadDict()
|
||||
let url = ((root["gateway"] as? [String: Any])?["remote"] as? [String: Any])?["url"] as? String
|
||||
#expect(url == "wss://new-host:2222")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
func stateDirOverrideSetsConfigPath() async {
|
||||
let dir = FileManager().temporaryDirectory
|
||||
.appendingPathComponent("openclaw-state-\(UUID().uuidString)", isDirectory: true)
|
||||
.path
|
||||
|
||||
await TestIsolation.withEnvValues([
|
||||
"OPENCLAW_CONFIG_PATH": nil,
|
||||
"OPENCLAW_STATE_DIR": dir,
|
||||
]) {
|
||||
#expect(OpenClawConfigFile.stateDirURL().path == dir)
|
||||
#expect(OpenClawConfigFile.url().path == "\(dir)/openclaw.json")
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
-13
@@ -1,20 +1,20 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite
|
||||
struct MoltbotOAuthStoreTests {
|
||||
struct OpenClawOAuthStoreTests {
|
||||
@Test
|
||||
func returnsMissingWhenFileAbsent() {
|
||||
let url = FileManager().temporaryDirectory
|
||||
.appendingPathComponent("moltbot-oauth-\(UUID().uuidString)")
|
||||
.appendingPathComponent("openclaw-oauth-\(UUID().uuidString)")
|
||||
.appendingPathComponent("oauth.json")
|
||||
#expect(MoltbotOAuthStore.anthropicOAuthStatus(at: url) == .missingFile)
|
||||
#expect(OpenClawOAuthStore.anthropicOAuthStatus(at: url) == .missingFile)
|
||||
}
|
||||
|
||||
@Test
|
||||
func usesEnvOverrideForMoltbotOAuthDir() throws {
|
||||
let key = "CLAWDBOT_OAUTH_DIR"
|
||||
func usesEnvOverrideForOpenClawOAuthDir() throws {
|
||||
let key = "OPENCLAW_OAUTH_DIR"
|
||||
let previous = ProcessInfo.processInfo.environment[key]
|
||||
defer {
|
||||
if let previous {
|
||||
@@ -25,10 +25,10 @@ struct MoltbotOAuthStoreTests {
|
||||
}
|
||||
|
||||
let dir = FileManager().temporaryDirectory
|
||||
.appendingPathComponent("moltbot-oauth-\(UUID().uuidString)", isDirectory: true)
|
||||
.appendingPathComponent("openclaw-oauth-\(UUID().uuidString)", isDirectory: true)
|
||||
setenv(key, dir.path, 1)
|
||||
|
||||
#expect(MoltbotOAuthStore.oauthDir().standardizedFileURL == dir.standardizedFileURL)
|
||||
#expect(OpenClawOAuthStore.oauthDir().standardizedFileURL == dir.standardizedFileURL)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -42,7 +42,7 @@ struct MoltbotOAuthStoreTests {
|
||||
],
|
||||
])
|
||||
|
||||
#expect(MoltbotOAuthStore.anthropicOAuthStatus(at: url).isConnected)
|
||||
#expect(OpenClawOAuthStore.anthropicOAuthStatus(at: url).isConnected)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -55,7 +55,7 @@ struct MoltbotOAuthStoreTests {
|
||||
],
|
||||
])
|
||||
|
||||
#expect(MoltbotOAuthStore.anthropicOAuthStatus(at: url).isConnected)
|
||||
#expect(OpenClawOAuthStore.anthropicOAuthStatus(at: url).isConnected)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -68,7 +68,7 @@ struct MoltbotOAuthStoreTests {
|
||||
],
|
||||
])
|
||||
|
||||
#expect(MoltbotOAuthStore.anthropicOAuthStatus(at: url) == .missingProviderEntry)
|
||||
#expect(OpenClawOAuthStore.anthropicOAuthStatus(at: url) == .missingProviderEntry)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -81,12 +81,12 @@ struct MoltbotOAuthStoreTests {
|
||||
],
|
||||
])
|
||||
|
||||
#expect(MoltbotOAuthStore.anthropicOAuthStatus(at: url) == .missingTokens)
|
||||
#expect(OpenClawOAuthStore.anthropicOAuthStatus(at: url) == .missingTokens)
|
||||
}
|
||||
|
||||
private func writeOAuthFile(_ json: [String: Any]) throws -> URL {
|
||||
let dir = FileManager().temporaryDirectory
|
||||
.appendingPathComponent("moltbot-oauth-\(UUID().uuidString)", isDirectory: true)
|
||||
.appendingPathComponent("openclaw-oauth-\(UUID().uuidString)", isDirectory: true)
|
||||
try FileManager().createDirectory(at: dir, withIntermediateDirectories: true)
|
||||
|
||||
let url = dir.appendingPathComponent("oauth.json")
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import CoreLocation
|
||||
import Testing
|
||||
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite("PermissionManager Location")
|
||||
struct PermissionManagerLocationTests {
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
import MoltbotIPC
|
||||
import OpenClawIPC
|
||||
import CoreLocation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized)
|
||||
@MainActor
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
#if canImport(Darwin)
|
||||
import Darwin
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite struct RuntimeLocatorTests {
|
||||
private func makeTempExecutable(contents: String) throws -> URL {
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite
|
||||
struct ScreenshotSizeTests {
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite struct SemverTests {
|
||||
@Test func comparisonOrdersByMajorMinorPatch() {
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite
|
||||
struct SessionDataTests {
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized)
|
||||
struct SessionMenuPreviewTests {
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
import SwiftUI
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized)
|
||||
@MainActor
|
||||
@@ -8,7 +8,7 @@ struct SettingsViewSmokeTests {
|
||||
@Test func cronSettingsBuildsBody() {
|
||||
let store = CronJobsStore(isPreview: true)
|
||||
store.schedulerEnabled = false
|
||||
store.schedulerStorePath = "/tmp/moltbot-cron-store.json"
|
||||
store.schedulerStorePath = "/tmp/openclaw-cron-store.json"
|
||||
|
||||
let job1 = CronJob(
|
||||
id: "job-1",
|
||||
+6
-6
@@ -1,6 +1,6 @@
|
||||
import MoltbotProtocol
|
||||
import OpenClawProtocol
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized)
|
||||
@MainActor
|
||||
@@ -12,7 +12,7 @@ struct SkillsSettingsSmokeTests {
|
||||
SkillStatus(
|
||||
name: "Needs Setup",
|
||||
description: "Missing bins and env",
|
||||
source: "moltbot-managed",
|
||||
source: "openclaw-managed",
|
||||
filePath: "/tmp/skills/needs-setup",
|
||||
baseDir: "/tmp/skills",
|
||||
skillKey: "needs-setup",
|
||||
@@ -39,7 +39,7 @@ struct SkillsSettingsSmokeTests {
|
||||
SkillStatus(
|
||||
name: "Ready Skill",
|
||||
description: "All set",
|
||||
source: "moltbot-bundled",
|
||||
source: "openclaw-bundled",
|
||||
filePath: "/tmp/skills/ready",
|
||||
baseDir: "/tmp/skills",
|
||||
skillKey: "ready",
|
||||
@@ -59,7 +59,7 @@ struct SkillsSettingsSmokeTests {
|
||||
SkillStatus(
|
||||
name: "Disabled Skill",
|
||||
description: "Disabled in config",
|
||||
source: "moltbot-extra",
|
||||
source: "openclaw-extra",
|
||||
filePath: "/tmp/skills/disabled",
|
||||
baseDir: "/tmp/skills",
|
||||
skillKey: "disabled",
|
||||
@@ -90,7 +90,7 @@ struct SkillsSettingsSmokeTests {
|
||||
SkillStatus(
|
||||
name: "Local Skill",
|
||||
description: "Local ready",
|
||||
source: "moltbot-workspace",
|
||||
source: "openclaw-workspace",
|
||||
filePath: "/tmp/skills/local",
|
||||
baseDir: "/tmp/skills",
|
||||
skillKey: "local",
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
import SwiftUI
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized)
|
||||
@MainActor
|
||||
@@ -17,7 +17,7 @@ struct TailscaleIntegrationSectionTests {
|
||||
let service = TailscaleService(
|
||||
isInstalled: true,
|
||||
isRunning: true,
|
||||
tailscaleHostname: "moltbot.tailnet.ts.net",
|
||||
tailscaleHostname: "openclaw.tailnet.ts.net",
|
||||
tailscaleIP: "100.64.0.1")
|
||||
var view = TailscaleIntegrationSection(connectionMode: .local, isPaused: false)
|
||||
view.setTestingService(service)
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized) struct TalkAudioPlayerTests {
|
||||
@MainActor
|
||||
+1
-1
@@ -110,7 +110,7 @@ enum TestIsolation {
|
||||
|
||||
nonisolated static func tempConfigPath() -> String {
|
||||
FileManager().temporaryDirectory
|
||||
.appendingPathComponent("moltbot-test-config-\(UUID().uuidString).json")
|
||||
.appendingPathComponent("openclaw-test-config-\(UUID().uuidString).json")
|
||||
.path
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -1,6 +1,6 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized) struct UtilitiesTests {
|
||||
@Test func ageStringsCoverCommonWindows() {
|
||||
@@ -46,7 +46,7 @@ import Testing
|
||||
let tmp = URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true)
|
||||
.appendingPathComponent(UUID().uuidString, isDirectory: true)
|
||||
let dist = tmp.appendingPathComponent("dist/index.js")
|
||||
let bin = tmp.appendingPathComponent("bin/moltbot.js")
|
||||
let bin = tmp.appendingPathComponent("bin/openclaw.js")
|
||||
try FileManager().createDirectory(at: dist.deletingLastPathComponent(), withIntermediateDirectories: true)
|
||||
try FileManager().createDirectory(at: bin.deletingLastPathComponent(), withIntermediateDirectories: true)
|
||||
FileManager().createFile(atPath: dist.path, contents: Data())
|
||||
@@ -58,11 +58,11 @@ import Testing
|
||||
|
||||
@Test func logLocatorPicksNewestLogFile() throws {
|
||||
let fm = FileManager()
|
||||
let dir = URL(fileURLWithPath: "/tmp/moltbot", isDirectory: true)
|
||||
let dir = URL(fileURLWithPath: "/tmp/openclaw", isDirectory: true)
|
||||
try? fm.createDirectory(at: dir, withIntermediateDirectories: true)
|
||||
|
||||
let older = dir.appendingPathComponent("moltbot-old-\(UUID().uuidString).log")
|
||||
let newer = dir.appendingPathComponent("moltbot-new-\(UUID().uuidString).log")
|
||||
let older = dir.appendingPathComponent("openclaw-old-\(UUID().uuidString).log")
|
||||
let newer = dir.appendingPathComponent("openclaw-new-\(UUID().uuidString).log")
|
||||
fm.createFile(atPath: older.path, contents: Data("old".utf8))
|
||||
fm.createFile(atPath: newer.path, contents: Data("new".utf8))
|
||||
try fm.setAttributes([.modificationDate: Date(timeIntervalSinceNow: -100)], ofItemAtPath: older.path)
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import AppKit
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized) struct VoicePushToTalkHotkeyTests {
|
||||
actor Counter {
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite struct VoicePushToTalkTests {
|
||||
@Test func deltaTrimsCommittedPrefix() {
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized) struct VoiceWakeForwarderTests {
|
||||
@Test func prefixedTranscriptUsesMachineName() {
|
||||
+5
-5
@@ -1,7 +1,7 @@
|
||||
import MoltbotProtocol
|
||||
import OpenClawProtocol
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized) struct VoiceWakeGlobalSettingsSyncTests {
|
||||
@Test func appliesVoiceWakeChangedEventToAppState() async {
|
||||
@@ -11,7 +11,7 @@ import Testing
|
||||
AppStateStore.shared.applyGlobalVoiceWakeTriggers(["before"])
|
||||
}
|
||||
|
||||
let payload = MoltbotProtocol.AnyCodable(["triggers": ["clawd", "computer"]])
|
||||
let payload = OpenClawProtocol.AnyCodable(["triggers": ["openclaw", "computer"]])
|
||||
let evt = EventFrame(
|
||||
type: "event",
|
||||
event: "voicewake.changed",
|
||||
@@ -22,7 +22,7 @@ import Testing
|
||||
await VoiceWakeGlobalSettingsSync.shared.handle(push: .event(evt))
|
||||
|
||||
let updated = await MainActor.run { AppStateStore.shared.swabbleTriggerWords }
|
||||
#expect(updated == ["clawd", "computer"])
|
||||
#expect(updated == ["openclaw", "computer"])
|
||||
|
||||
await MainActor.run {
|
||||
AppStateStore.shared.applyGlobalVoiceWakeTriggers(previous)
|
||||
@@ -36,7 +36,7 @@ import Testing
|
||||
AppStateStore.shared.applyGlobalVoiceWakeTriggers(["before"])
|
||||
}
|
||||
|
||||
let payload = MoltbotProtocol.AnyCodable(["unexpected": 123])
|
||||
let payload = OpenClawProtocol.AnyCodable(["unexpected": 123])
|
||||
let evt = EventFrame(
|
||||
type: "event",
|
||||
event: "voicewake.changed",
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
struct VoiceWakeHelpersTests {
|
||||
@Test func sanitizeTriggersTrimsAndDropsEmpty() {
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized)
|
||||
@MainActor
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite struct VoiceWakeOverlayTests {
|
||||
@Test func guardTokenDropsWhenNoActive() {
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import SwiftUI
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized)
|
||||
@MainActor
|
||||
+10
-10
@@ -1,11 +1,11 @@
|
||||
import Foundation
|
||||
import SwabbleKit
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite struct VoiceWakeRuntimeTests {
|
||||
@Test func trimsAfterTriggerKeepsPostSpeech() {
|
||||
let triggers = ["claude", "clawd"]
|
||||
let triggers = ["claude", "openclaw"]
|
||||
let text = "hey Claude how are you"
|
||||
#expect(VoiceWakeRuntime._testTrimmedAfterTrigger(text, triggers: triggers) == "how are you")
|
||||
}
|
||||
@@ -24,8 +24,8 @@ import Testing
|
||||
}
|
||||
|
||||
@Test func hasContentAfterTriggerFalseWhenOnlyTrigger() {
|
||||
let triggers = ["clawd"]
|
||||
let text = "hey clawd"
|
||||
let triggers = ["openclaw"]
|
||||
let text = "hey openclaw"
|
||||
#expect(!VoiceWakeRuntime._testHasContentAfterTrigger(text, triggers: triggers))
|
||||
}
|
||||
|
||||
@@ -36,30 +36,30 @@ import Testing
|
||||
}
|
||||
|
||||
@Test func gateRequiresGapBetweenTriggerAndCommand() {
|
||||
let transcript = "hey clawd do thing"
|
||||
let transcript = "hey openclaw do thing"
|
||||
let segments = makeSegments(
|
||||
transcript: transcript,
|
||||
words: [
|
||||
("hey", 0.0, 0.1),
|
||||
("clawd", 0.2, 0.1),
|
||||
("openclaw", 0.2, 0.1),
|
||||
("do", 0.35, 0.1),
|
||||
("thing", 0.5, 0.1),
|
||||
])
|
||||
let config = WakeWordGateConfig(triggers: ["clawd"], minPostTriggerGap: 0.3)
|
||||
let config = WakeWordGateConfig(triggers: ["openclaw"], minPostTriggerGap: 0.3)
|
||||
#expect(WakeWordGate.match(transcript: transcript, segments: segments, config: config) == nil)
|
||||
}
|
||||
|
||||
@Test func gateAcceptsGapAndExtractsCommand() {
|
||||
let transcript = "hey clawd do thing"
|
||||
let transcript = "hey openclaw do thing"
|
||||
let segments = makeSegments(
|
||||
transcript: transcript,
|
||||
words: [
|
||||
("hey", 0.0, 0.1),
|
||||
("clawd", 0.2, 0.1),
|
||||
("openclaw", 0.2, 0.1),
|
||||
("do", 0.9, 0.1),
|
||||
("thing", 1.1, 0.1),
|
||||
])
|
||||
let config = WakeWordGateConfig(triggers: ["clawd"], minPostTriggerGap: 0.3)
|
||||
let config = WakeWordGateConfig(triggers: ["openclaw"], minPostTriggerGap: 0.3)
|
||||
#expect(WakeWordGate.match(transcript: transcript, segments: segments, config: config)?.command == "do thing")
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,12 +1,12 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite struct WebChatMainSessionKeyTests {
|
||||
@Test func configGetSnapshotMainKeyFallsBackToMainWhenMissing() throws {
|
||||
let json = """
|
||||
{
|
||||
"path": "/Users/pete/.clawdbot/moltbot.json",
|
||||
"path": "/Users/pete/.openclaw/openclaw.json",
|
||||
"exists": true,
|
||||
"raw": null,
|
||||
"parsed": {},
|
||||
@@ -22,7 +22,7 @@ import Testing
|
||||
@Test func configGetSnapshotMainKeyTrimsAndUsesValue() throws {
|
||||
let json = """
|
||||
{
|
||||
"path": "/Users/pete/.clawdbot/moltbot.json",
|
||||
"path": "/Users/pete/.openclaw/openclaw.json",
|
||||
"exists": true,
|
||||
"raw": null,
|
||||
"parsed": {},
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized)
|
||||
@MainActor
|
||||
+8
-8
@@ -1,18 +1,18 @@
|
||||
import AppKit
|
||||
import MoltbotChatUI
|
||||
import OpenClawChatUI
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized)
|
||||
@MainActor
|
||||
struct WebChatSwiftUISmokeTests {
|
||||
private struct TestTransport: MoltbotChatTransport, Sendable {
|
||||
func requestHistory(sessionKey: String) async throws -> MoltbotChatHistoryPayload {
|
||||
private struct TestTransport: OpenClawChatTransport, Sendable {
|
||||
func requestHistory(sessionKey: String) async throws -> OpenClawChatHistoryPayload {
|
||||
let json = """
|
||||
{"sessionKey":"\(sessionKey)","sessionId":null,"messages":[],"thinkingLevel":"off"}
|
||||
"""
|
||||
return try JSONDecoder().decode(MoltbotChatHistoryPayload.self, from: Data(json.utf8))
|
||||
return try JSONDecoder().decode(OpenClawChatHistoryPayload.self, from: Data(json.utf8))
|
||||
}
|
||||
|
||||
func sendMessage(
|
||||
@@ -20,17 +20,17 @@ struct WebChatSwiftUISmokeTests {
|
||||
message _: String,
|
||||
thinking _: String,
|
||||
idempotencyKey _: String,
|
||||
attachments _: [MoltbotChatAttachmentPayload]) async throws -> MoltbotChatSendResponse
|
||||
attachments _: [OpenClawChatAttachmentPayload]) async throws -> OpenClawChatSendResponse
|
||||
{
|
||||
let json = """
|
||||
{"runId":"\(UUID().uuidString)","status":"ok"}
|
||||
"""
|
||||
return try JSONDecoder().decode(MoltbotChatSendResponse.self, from: Data(json.utf8))
|
||||
return try JSONDecoder().decode(OpenClawChatSendResponse.self, from: Data(json.utf8))
|
||||
}
|
||||
|
||||
func requestHealth(timeoutMs _: Int) async throws -> Bool { true }
|
||||
|
||||
func events() -> AsyncStream<MoltbotChatTransportEvent> {
|
||||
func events() -> AsyncStream<OpenClawChatTransportEvent> {
|
||||
AsyncStream { continuation in
|
||||
continuation.finish()
|
||||
}
|
||||
+7
-6
@@ -1,9 +1,10 @@
|
||||
import Testing
|
||||
@testable import MoltbotDiscovery
|
||||
@testable import OpenClawDiscovery
|
||||
|
||||
@Suite
|
||||
struct WideAreaGatewayDiscoveryTests {
|
||||
@Test func discoversBeaconFromTailnetDnsSdFallback() {
|
||||
setenv("OPENCLAW_WIDE_AREA_DOMAIN", "openclaw.internal", 1)
|
||||
let statusJson = """
|
||||
{
|
||||
"Self": { "TailscaleIPs": ["100.69.232.64"] },
|
||||
@@ -20,15 +21,15 @@ struct WideAreaGatewayDiscoveryTests {
|
||||
let nameserver = args.first(where: { $0.hasPrefix("@") }) ?? ""
|
||||
if recordType == "PTR" {
|
||||
if nameserver == "@100.123.224.76" {
|
||||
return "steipetacstudio-gateway._moltbot-gw._tcp.clawdbot.internal.\n"
|
||||
return "steipetacstudio-gateway._openclaw-gw._tcp.openclaw.internal.\n"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
if recordType == "SRV" {
|
||||
return "0 0 18789 steipetacstudio.clawdbot.internal."
|
||||
return "0 0 18789 steipetacstudio.openclaw.internal."
|
||||
}
|
||||
if recordType == "TXT" {
|
||||
return "\"displayName=Peter\\226\\128\\153s Mac Studio (Moltbot)\" \"gatewayPort=18789\" \"tailnetDns=peters-mac-studio-1.sheep-coho.ts.net\" \"cliPath=/Users/steipete/moltbot/src/entry.ts\""
|
||||
return "\"displayName=Peter\\226\\128\\153s Mac Studio (OpenClaw)\" \"gatewayPort=18789\" \"tailnetDns=peters-mac-studio-1.sheep-coho.ts.net\" \"cliPath=/Users/steipete/openclaw/src/entry.ts\""
|
||||
}
|
||||
return ""
|
||||
})
|
||||
@@ -39,11 +40,11 @@ struct WideAreaGatewayDiscoveryTests {
|
||||
|
||||
#expect(beacons.count == 1)
|
||||
let beacon = beacons[0]
|
||||
let expectedDisplay = "Peter\u{2019}s Mac Studio (Moltbot)"
|
||||
let expectedDisplay = "Peter\u{2019}s Mac Studio (OpenClaw)"
|
||||
#expect(beacon.displayName == expectedDisplay)
|
||||
#expect(beacon.port == 18789)
|
||||
#expect(beacon.gatewayPort == 18789)
|
||||
#expect(beacon.tailnetDns == "peters-mac-studio-1.sheep-coho.ts.net")
|
||||
#expect(beacon.cliPath == "/Users/steipete/moltbot/src/entry.ts")
|
||||
#expect(beacon.cliPath == "/Users/steipete/openclaw/src/entry.ts")
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import AppKit
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite
|
||||
@MainActor
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
import MoltbotProtocol
|
||||
import OpenClawProtocol
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Moltbot
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite
|
||||
@MainActor
|
||||
@@ -68,7 +68,7 @@ struct WorkActivityStoreTests {
|
||||
meta: nil,
|
||||
args: [
|
||||
"command": AnyCodable("echo hi\necho bye"),
|
||||
"path": AnyCodable("\(home)/Projects/moltbot"),
|
||||
"path": AnyCodable("\(home)/Projects/openclaw"),
|
||||
])
|
||||
|
||||
#expect(store.current?.label == "bash: echo hi")
|
||||
Reference in New Issue
Block a user