fix deleting directory

this used to corrupt the local state (password entities remained in DB
but files/dirs were removed from git and disk)
This commit is contained in:
Lysann Tranvouez 2026-03-09 12:11:37 +01:00
parent 12c8c04203
commit 98646242e0
4 changed files with 24 additions and 0 deletions

View file

@ -143,9 +143,27 @@ final class PasswordStoreTest: XCTestCase {
try passwordStore.delete(passwordEntity: entity!)
XCTAssertNil(passwordStore.fetchPasswordEntity(with: "personal/github.com.gpg"))
XCTAssertNil(passwordStore.fetchPasswordEntity(with: "personal"))
XCTAssertFalse(FileManager.default.fileExists(atPath: localRepoURL.appendingPathComponent("personal").path))
waitForExpectations(timeout: 1, handler: nil)
}
func testDeleteDirectoryFails() throws {
try cloneRepository(.withGPGID)
expectation(forNotification: .passwordStoreUpdated, object: nil).isInverted = true
let entity = passwordStore.fetchPasswordEntity(with: "personal")
XCTAssertThrowsError(try passwordStore.delete(passwordEntity: entity!)) { error in
XCTAssertTrue(error is AppError, "Unexpected error type: \(type(of: error))")
XCTAssertEqual(error as? AppError, .cannotDeleteDirectory)
}
XCTAssertNotNil(passwordStore.fetchPasswordEntity(with: "personal/github.com.gpg"))
XCTAssertTrue(FileManager.default.fileExists(atPath: localRepoURL.appendingPathComponent("personal/github.com.gpg").path))
waitForExpectations(timeout: 0.1, handler: nil)
}
func testEditPasswordValue() throws {
try cloneRepository(.withGPGID)
try importSinglePGPKey()