2025-12-13 18:08:47 +00:00
|
|
|
import Foundation
|
|
|
|
|
import Testing
|
2026-01-30 03:15:10 +01:00
|
|
|
@testable import OpenClaw
|
2025-12-13 18:08:47 +00:00
|
|
|
|
|
|
|
|
@Suite struct NodeManagerPathsTests {
|
|
|
|
|
@Test func fnmNodeBinsPreferNewestInstalledVersion() throws {
|
2026-03-02 09:39:30 +00:00
|
|
|
let home = try makeTempDirForTests()
|
2025-12-13 18:08:47 +00:00
|
|
|
|
|
|
|
|
let v20Bin = home
|
|
|
|
|
.appendingPathComponent(".local/share/fnm/node-versions/v20.19.5/installation/bin/node")
|
|
|
|
|
let v25Bin = home
|
|
|
|
|
.appendingPathComponent(".local/share/fnm/node-versions/v25.1.0/installation/bin/node")
|
2026-03-02 09:39:30 +00:00
|
|
|
try makeExecutableForTests(at: v20Bin)
|
|
|
|
|
try makeExecutableForTests(at: v25Bin)
|
2025-12-13 18:08:47 +00:00
|
|
|
|
|
|
|
|
let bins = CommandResolver._testNodeManagerBinPaths(home: home)
|
|
|
|
|
#expect(bins.first == v25Bin.deletingLastPathComponent().path)
|
|
|
|
|
#expect(bins.contains(v20Bin.deletingLastPathComponent().path))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test func ignoresEntriesWithoutNodeExecutable() throws {
|
2026-03-02 09:39:30 +00:00
|
|
|
let home = try makeTempDirForTests()
|
2025-12-13 18:08:47 +00:00
|
|
|
let missingNodeBin = home
|
|
|
|
|
.appendingPathComponent(".local/share/fnm/node-versions/v99.0.0/installation/bin")
|
2026-01-18 20:00:26 +01:00
|
|
|
try FileManager().createDirectory(at: missingNodeBin, withIntermediateDirectories: true)
|
2025-12-13 18:08:47 +00:00
|
|
|
|
|
|
|
|
let bins = CommandResolver._testNodeManagerBinPaths(home: home)
|
|
|
|
|
#expect(!bins.contains(missingNodeBin.path))
|
|
|
|
|
}
|
|
|
|
|
}
|