before the great git rework

This commit is contained in:
2026-10-30 11:27:44 +01:00
parent 9bdda896af
commit b9c03a7637
45 changed files with 70 additions and 562 deletions
@@ -1,33 +0,0 @@
import Foundation
import HelderCore
import HelderServices
/// The project note in memory; records every write.
final class FakeNotes: NotesServicing, @unchecked Sendable {
private let state: Locked<(stored: String, writes: [String], failWrites: Bool)>
init(_ stored: String = "") {
state = Locked((stored, [], false))
}
var writes: [String] { state.current.writes }
var onDisk: String { state.current.stored }
var failWrites: Bool {
get { state.current.failWrites }
set { state.mutate { $0.failWrites = newValue } }
}
/// Another program rewrote the note file.
func setOnDisk(_ text: String) { state.mutate { $0.stored = text } }
func read() async -> String { state.current.stored }
func write(_ text: String) async throws {
try state.mutate { state in
if state.failWrites { throw CocoaError(.fileWriteNoPermission) }
state.writes.append(text)
state.stored = text
}
}
}
@@ -11,7 +11,6 @@ struct WorkspaceHarness {
let git: FakeGit
let files: FakeFiles
let config: FakeConfig
let notes: FakeNotes
let symbols: FakeSymbols
let recentFiles: FakeRecentFiles
let recents: FakeRecentProjects
@@ -27,13 +26,12 @@ struct WorkspaceHarness {
var last: FakeWatcher? { made.last }
}
init(root: URL? = URL(fileURLWithPath: "/fake/project"), config: HelderConfig = .defaults, note: String = "",
init(root: URL? = URL(fileURLWithPath: "/fake/project"), config: HelderConfig = .defaults,
git: GitSnapshot? = nil, tree: FileNode = sampleTree(), contents: [String: String] = [:],
recents: [RecentProject] = [], session: FakeSession = FakeSession()) {
let git = FakeGit(git)
let files = FakeFiles(tree: tree, contents: contents, root: root ?? URL(fileURLWithPath: "/"))
let config = FakeConfig(config)
let notes = FakeNotes(note)
let symbols = FakeSymbols()
let recentFiles = FakeRecentFiles()
let recentStore = FakeRecentProjects(recents)
@@ -45,7 +43,7 @@ struct WorkspaceHarness {
recentProjects: recentStore, session: session, layouts: layouts, system: system, speech: speech,
makeWorkspace: { _ in
WorkspaceServices(git: git, files: files, search: FakeSearch(), symbols: symbols,
config: config, notes: notes, recentFiles: recentFiles)
config: config, recentFiles: recentFiles)
},
makeWatcher: {
let watcher = FakeWatcher()
@@ -58,7 +56,6 @@ struct WorkspaceHarness {
self.git = git
self.files = files
self.config = config
self.notes = notes
self.symbols = symbols
self.recentFiles = recentFiles
self.recents = recentStore