feat(macos): prompt for CLI install
This commit is contained in:
@@ -5,39 +5,30 @@ import Testing
|
||||
@Suite(.serialized)
|
||||
@MainActor
|
||||
struct CLIInstallerTests {
|
||||
@Test func installedLocationOnlyAcceptsEmbeddedHelper() throws {
|
||||
@Test func installedLocationFindsExecutable() throws {
|
||||
let fm = FileManager.default
|
||||
let root = fm.temporaryDirectory.appendingPathComponent(
|
||||
"clawdbot-cli-installer-\(UUID().uuidString)")
|
||||
defer { try? fm.removeItem(at: root) }
|
||||
|
||||
let embedded = root.appendingPathComponent("Relay/clawdbot")
|
||||
try fm.createDirectory(at: embedded.deletingLastPathComponent(), withIntermediateDirectories: true)
|
||||
fm.createFile(atPath: embedded.path, contents: Data())
|
||||
try fm.setAttributes([.posixPermissions: 0o755], ofItemAtPath: embedded.path)
|
||||
|
||||
let binDir = root.appendingPathComponent("bin")
|
||||
try fm.createDirectory(at: binDir, withIntermediateDirectories: true)
|
||||
let link = binDir.appendingPathComponent("clawdbot")
|
||||
try fm.createSymbolicLink(at: link, withDestinationURL: embedded)
|
||||
let cli = binDir.appendingPathComponent("clawdbot")
|
||||
fm.createFile(atPath: cli.path, contents: Data())
|
||||
try fm.setAttributes([.posixPermissions: 0o755], ofItemAtPath: cli.path)
|
||||
|
||||
let found = CLIInstaller.installedLocation(
|
||||
searchPaths: [binDir.path],
|
||||
embeddedHelper: embedded,
|
||||
fileManager: fm)
|
||||
#expect(found == link.path)
|
||||
#expect(found == cli.path)
|
||||
|
||||
try fm.removeItem(at: link)
|
||||
let other = root.appendingPathComponent("Other/clawdbot")
|
||||
try fm.createDirectory(at: other.deletingLastPathComponent(), withIntermediateDirectories: true)
|
||||
fm.createFile(atPath: other.path, contents: Data())
|
||||
try fm.setAttributes([.posixPermissions: 0o755], ofItemAtPath: other.path)
|
||||
try fm.createSymbolicLink(at: link, withDestinationURL: other)
|
||||
try fm.removeItem(at: cli)
|
||||
fm.createFile(atPath: cli.path, contents: Data())
|
||||
try fm.setAttributes([.posixPermissions: 0o644], ofItemAtPath: cli.path)
|
||||
|
||||
let rejected = CLIInstaller.installedLocation(
|
||||
let missing = CLIInstaller.installedLocation(
|
||||
searchPaths: [binDir.path],
|
||||
embeddedHelper: embedded,
|
||||
fileManager: fm)
|
||||
#expect(rejected == nil)
|
||||
#expect(missing == nil)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,10 +123,6 @@ struct LowCoverageHelperTests {
|
||||
#expect(
|
||||
GatewayLaunchAgentManager._testEscapePlistValue("a&b<c>\"'") ==
|
||||
"a&b<c>"'")
|
||||
|
||||
#expect(GatewayLaunchAgentManager
|
||||
._testGatewayExecutablePath(bundlePath: "/App") == "/App/Contents/Resources/Relay/clawdbot")
|
||||
#expect(GatewayLaunchAgentManager._testRelayDir(bundlePath: "/App") == "/App/Contents/Resources/Relay")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user