refactor(macos): replace FileManager.default for Swift 6
This commit is contained in:
committed by
Peter Steinberger
parent
44d55667de
commit
87d995bcde
@@ -6,7 +6,7 @@ import Testing
|
||||
struct AgentWorkspaceTests {
|
||||
@Test
|
||||
func displayPathUsesTildeForHome() {
|
||||
let home = FileManager.default.homeDirectoryForCurrentUser
|
||||
let home = FileManager().homeDirectoryForCurrentUser
|
||||
#expect(AgentWorkspace.displayPath(for: home) == "~")
|
||||
|
||||
let inside = home.appendingPathComponent("Projects", isDirectory: true)
|
||||
@@ -28,12 +28,12 @@ struct AgentWorkspaceTests {
|
||||
|
||||
@Test
|
||||
func bootstrapCreatesAgentsFileWhenMissing() throws {
|
||||
let tmp = FileManager.default.temporaryDirectory
|
||||
let tmp = FileManager().temporaryDirectory
|
||||
.appendingPathComponent("clawdbot-ws-\(UUID().uuidString)", isDirectory: true)
|
||||
defer { try? FileManager.default.removeItem(at: tmp) }
|
||||
defer { try? FileManager().removeItem(at: tmp) }
|
||||
|
||||
let agentsURL = try AgentWorkspace.bootstrap(workspaceURL: tmp)
|
||||
#expect(FileManager.default.fileExists(atPath: agentsURL.path))
|
||||
#expect(FileManager().fileExists(atPath: agentsURL.path))
|
||||
|
||||
let contents = try String(contentsOf: agentsURL, encoding: .utf8)
|
||||
#expect(contents.contains("# AGENTS.md"))
|
||||
@@ -41,9 +41,9 @@ struct AgentWorkspaceTests {
|
||||
let identityURL = tmp.appendingPathComponent(AgentWorkspace.identityFilename)
|
||||
let userURL = tmp.appendingPathComponent(AgentWorkspace.userFilename)
|
||||
let bootstrapURL = tmp.appendingPathComponent(AgentWorkspace.bootstrapFilename)
|
||||
#expect(FileManager.default.fileExists(atPath: identityURL.path))
|
||||
#expect(FileManager.default.fileExists(atPath: userURL.path))
|
||||
#expect(FileManager.default.fileExists(atPath: bootstrapURL.path))
|
||||
#expect(FileManager().fileExists(atPath: identityURL.path))
|
||||
#expect(FileManager().fileExists(atPath: userURL.path))
|
||||
#expect(FileManager().fileExists(atPath: bootstrapURL.path))
|
||||
|
||||
let second = try AgentWorkspace.bootstrap(workspaceURL: tmp)
|
||||
#expect(second == agentsURL)
|
||||
@@ -51,10 +51,10 @@ struct AgentWorkspaceTests {
|
||||
|
||||
@Test
|
||||
func bootstrapSafetyRejectsNonEmptyFolderWithoutAgents() throws {
|
||||
let tmp = FileManager.default.temporaryDirectory
|
||||
let tmp = FileManager().temporaryDirectory
|
||||
.appendingPathComponent("clawdbot-ws-\(UUID().uuidString)", isDirectory: true)
|
||||
defer { try? FileManager.default.removeItem(at: tmp) }
|
||||
try FileManager.default.createDirectory(at: tmp, withIntermediateDirectories: true)
|
||||
defer { try? FileManager().removeItem(at: tmp) }
|
||||
try FileManager().createDirectory(at: tmp, withIntermediateDirectories: true)
|
||||
let marker = tmp.appendingPathComponent("notes.txt")
|
||||
try "hello".write(to: marker, atomically: true, encoding: .utf8)
|
||||
|
||||
@@ -69,10 +69,10 @@ struct AgentWorkspaceTests {
|
||||
|
||||
@Test
|
||||
func bootstrapSafetyAllowsExistingAgentsFile() throws {
|
||||
let tmp = FileManager.default.temporaryDirectory
|
||||
let tmp = FileManager().temporaryDirectory
|
||||
.appendingPathComponent("clawdbot-ws-\(UUID().uuidString)", isDirectory: true)
|
||||
defer { try? FileManager.default.removeItem(at: tmp) }
|
||||
try FileManager.default.createDirectory(at: tmp, withIntermediateDirectories: true)
|
||||
defer { try? FileManager().removeItem(at: tmp) }
|
||||
try FileManager().createDirectory(at: tmp, withIntermediateDirectories: true)
|
||||
let agents = tmp.appendingPathComponent(AgentWorkspace.agentsFilename)
|
||||
try "# AGENTS.md".write(to: agents, atomically: true, encoding: .utf8)
|
||||
|
||||
@@ -87,25 +87,25 @@ struct AgentWorkspaceTests {
|
||||
|
||||
@Test
|
||||
func bootstrapSkipsBootstrapFileWhenWorkspaceHasContent() throws {
|
||||
let tmp = FileManager.default.temporaryDirectory
|
||||
let tmp = FileManager().temporaryDirectory
|
||||
.appendingPathComponent("clawdbot-ws-\(UUID().uuidString)", isDirectory: true)
|
||||
defer { try? FileManager.default.removeItem(at: tmp) }
|
||||
try FileManager.default.createDirectory(at: tmp, withIntermediateDirectories: true)
|
||||
defer { try? FileManager().removeItem(at: tmp) }
|
||||
try FileManager().createDirectory(at: tmp, withIntermediateDirectories: true)
|
||||
let marker = tmp.appendingPathComponent("notes.txt")
|
||||
try "hello".write(to: marker, atomically: true, encoding: .utf8)
|
||||
|
||||
_ = try AgentWorkspace.bootstrap(workspaceURL: tmp)
|
||||
|
||||
let bootstrapURL = tmp.appendingPathComponent(AgentWorkspace.bootstrapFilename)
|
||||
#expect(!FileManager.default.fileExists(atPath: bootstrapURL.path))
|
||||
#expect(!FileManager().fileExists(atPath: bootstrapURL.path))
|
||||
}
|
||||
|
||||
@Test
|
||||
func needsBootstrapFalseWhenIdentityAlreadySet() throws {
|
||||
let tmp = FileManager.default.temporaryDirectory
|
||||
let tmp = FileManager().temporaryDirectory
|
||||
.appendingPathComponent("clawdbot-ws-\(UUID().uuidString)", isDirectory: true)
|
||||
defer { try? FileManager.default.removeItem(at: tmp) }
|
||||
try FileManager.default.createDirectory(at: tmp, withIntermediateDirectories: true)
|
||||
defer { try? FileManager().removeItem(at: tmp) }
|
||||
try FileManager().createDirectory(at: tmp, withIntermediateDirectories: true)
|
||||
let identityURL = tmp.appendingPathComponent(AgentWorkspace.identityFilename)
|
||||
try """
|
||||
# IDENTITY.md - Agent Identity
|
||||
|
||||
Reference in New Issue
Block a user