Files
openclaw/apps/macos/Tests/OpenClawIPCTests/CLIInstallerTests.swift

35 lines
1.2 KiB
Swift
Raw Normal View History

import Foundation
import Testing
2026-01-30 03:15:10 +01:00
@testable import OpenClaw
@Suite(.serialized)
@MainActor
struct CLIInstallerTests {
2026-01-11 10:15:37 +00:00
@Test func installedLocationFindsExecutable() throws {
let fm = FileManager()
let root = fm.temporaryDirectory.appendingPathComponent(
2026-01-30 03:15:10 +01:00
"openclaw-cli-installer-\(UUID().uuidString)")
defer { try? fm.removeItem(at: root) }
let binDir = root.appendingPathComponent("bin")
try fm.createDirectory(at: binDir, withIntermediateDirectories: true)
2026-01-30 03:15:10 +01:00
let cli = binDir.appendingPathComponent("openclaw")
2026-01-11 10:15:37 +00:00
fm.createFile(atPath: cli.path, contents: Data())
try fm.setAttributes([.posixPermissions: 0o755], ofItemAtPath: cli.path)
let found = CLIInstaller.installedLocation(
searchPaths: [binDir.path],
fileManager: fm)
2026-01-11 10:15:37 +00:00
#expect(found == cli.path)
2026-01-11 10:15:37 +00:00
try fm.removeItem(at: cli)
fm.createFile(atPath: cli.path, contents: Data())
try fm.setAttributes([.posixPermissions: 0o644], ofItemAtPath: cli.path)
2026-01-11 10:15:37 +00:00
let missing = CLIInstaller.installedLocation(
searchPaths: [binDir.path],
fileManager: fm)
2026-01-11 10:15:37 +00:00
#expect(missing == nil)
}
}