test: launch-paths BLOCKER regression + isWritableDirectory unit tests
ReturnWatcherTests.swift: two new tests bracket the BLOCKER fix — one characterizes the old bug (FolderSettings.resolvedAppSupportPaths(), AirDrop- only, ignores the persisted OneDrive transport; the watcher ends up watching a stale isolated folder and misses a marked PDF dropped into the real OneDrive-mode folder), the other proves the fix (the exact launch/bootstrap construction — TransportSettings.resolvedAppSupportPaths() + watcher.updateWatchFolder() before start — detects it). Both isolated to temp dirs, including an explicit FolderSettings watch-folder override so the "bug" test's found.isEmpty assertion never depends on what's actually in Ben's real ~/Downloads (it does, in fact, already contain real marked-up Redline PDFs from prior testing — an earlier version of this test read the REAL Downloads folder and failed for exactly that reason). TransportSettingsTests.swift: three tests for OneDriveLocator.isWritableDirectory — true for an ordinary directory, false for one chmod'd 500 (permissions restored in teardown before removal), false for a plain file and for a nonexistent path. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ZiTXPbPCSjzPVsfoweAbp
This commit is contained in:
@@ -90,6 +90,38 @@ func oneDriveFolderUnavailableErrorDescriptionContainsThePath() throws {
|
||||
#expect(description.contains(path))
|
||||
}
|
||||
|
||||
@Test
|
||||
func isWritableDirectoryTrueForAnOrdinaryWritableDirectory() throws {
|
||||
let dir = try makeTransportTemporaryDirectory(prefix: "shotdeck-writable")
|
||||
defer { try? FileManager.default.removeItem(at: dir) }
|
||||
#expect(OneDriveLocator.isWritableDirectory(at: dir))
|
||||
}
|
||||
|
||||
@Test
|
||||
func isWritableDirectoryFalseForAnExistingButUnwritableDirectory() throws {
|
||||
let dir = try makeTransportTemporaryDirectory(prefix: "shotdeck-unwritable")
|
||||
defer {
|
||||
// Restore perms BEFORE removal — an unwritable dir can't otherwise be cleaned up.
|
||||
try? FileManager.default.setAttributes([.posixPermissions: 0o755], ofItemAtPath: dir.path)
|
||||
try? FileManager.default.removeItem(at: dir)
|
||||
}
|
||||
#expect(OneDriveLocator.isWritableDirectory(at: dir)) // sanity check before chmod
|
||||
|
||||
try FileManager.default.setAttributes([.posixPermissions: 0o500], ofItemAtPath: dir.path)
|
||||
#expect(!OneDriveLocator.isWritableDirectory(at: dir))
|
||||
}
|
||||
|
||||
@Test
|
||||
func isWritableDirectoryFalseForAPlainFileAndForANonexistentPath() throws {
|
||||
let dir = try makeTransportTemporaryDirectory(prefix: "shotdeck-writable-check-parent")
|
||||
defer { try? FileManager.default.removeItem(at: dir) }
|
||||
let filePath = dir.appendingPathComponent("plain-file.txt")
|
||||
FileManager.default.createFile(atPath: filePath.path, contents: Data("x".utf8))
|
||||
|
||||
#expect(!OneDriveLocator.isWritableDirectory(at: filePath))
|
||||
#expect(!OneDriveLocator.isWritableDirectory(at: dir.appendingPathComponent("does-not-exist")))
|
||||
}
|
||||
|
||||
struct TransportDefaultsSuite {
|
||||
let name: String
|
||||
let defaults: UserDefaults
|
||||
|
||||
Reference in New Issue
Block a user