fix test cleanup

This commit is contained in:
Lysann Tranvouez 2026-03-08 22:05:58 +01:00
parent 53ae6426bd
commit 17b6bb8bc2

View file

@ -19,7 +19,13 @@ final class PasswordStoreTest: XCTestCase {
let url = Globals.sharedContainerURL.appendingPathComponent("Library/password-store-test/") let url = Globals.sharedContainerURL.appendingPathComponent("Library/password-store-test/")
Defaults.isEnableGPGIDOn = true Defaults.isEnableGPGIDOn = true
defer {
Defaults.isEnableGPGIDOn = false
}
let passwordStore = PasswordStore(url: url) let passwordStore = PasswordStore(url: url)
defer {
passwordStore.erase()
}
try passwordStore.cloneRepository(remoteRepoURL: remoteRepoURL, branchName: "master") try passwordStore.cloneRepository(remoteRepoURL: remoteRepoURL, branchName: "master")
expectation(for: NSPredicate { _, _ in FileManager.default.fileExists(atPath: url.path) }, evaluatedWith: nil) expectation(for: NSPredicate { _, _ in FileManager.default.fileExists(atPath: url.path) }, evaluatedWith: nil)
waitForExpectations(timeout: 3, handler: nil) waitForExpectations(timeout: 3, handler: nil)
@ -47,9 +53,6 @@ final class PasswordStoreTest: XCTestCase {
let testPasswordEntity = try passwordStore.add(password: testPassword)! let testPasswordEntity = try passwordStore.add(password: testPassword)!
let testPasswordPlain = try passwordStore.decrypt(passwordEntity: testPasswordEntity, requestPGPKeyPassphrase: requestPGPKeyPassphrase) let testPasswordPlain = try passwordStore.decrypt(passwordEntity: testPasswordEntity, requestPGPKeyPassphrase: requestPGPKeyPassphrase)
XCTAssertEqual(testPasswordPlain.plainText, "testpassword") XCTAssertEqual(testPasswordPlain.plainText, "testpassword")
passwordStore.erase()
Defaults.isEnableGPGIDOn = false
} }
private func decrypt(passwordStore: PasswordStore, path: String, passphrase _: String) throws -> Password { private func decrypt(passwordStore: PasswordStore, path: String, passphrase _: String) throws -> Password {