check notification center notifications

This commit is contained in:
Lysann Tranvouez 2026-03-09 11:45:04 +01:00
parent e5650ec756
commit 98ad323431

View file

@ -56,11 +56,14 @@ final class PasswordStoreTest: XCTestCase {
XCTAssertGreaterThan(passwordStore.numberOfPasswords, 0) XCTAssertGreaterThan(passwordStore.numberOfPasswords, 0)
XCTAssertNotNil(passwordStore.gitRepository) XCTAssertNotNil(passwordStore.gitRepository)
expectation(forNotification: .passwordStoreUpdated, object: nil)
expectation(forNotification: .passwordStoreErased, object: nil)
passwordStore.eraseStoreData() passwordStore.eraseStoreData()
XCTAssertFalse(FileManager.default.fileExists(atPath: localRepoURL.path)) XCTAssertFalse(FileManager.default.fileExists(atPath: localRepoURL.path))
XCTAssertEqual(passwordStore.numberOfPasswords, 0) XCTAssertEqual(passwordStore.numberOfPasswords, 0)
XCTAssertNil(passwordStore.gitRepository) XCTAssertNil(passwordStore.gitRepository)
waitForExpectations(timeout: 1, handler: nil)
} }
func testErase() throws { func testErase() throws {
@ -75,6 +78,8 @@ final class PasswordStoreTest: XCTestCase {
XCTAssertTrue(PasscodeLock.shared.hasPasscode) XCTAssertTrue(PasscodeLock.shared.hasPasscode)
XCTAssertTrue(PGPAgent.shared.isInitialized()) XCTAssertTrue(PGPAgent.shared.isInitialized())
expectation(forNotification: .passwordStoreUpdated, object: nil)
expectation(forNotification: .passwordStoreErased, object: nil)
passwordStore.erase() passwordStore.erase()
XCTAssertEqual(passwordStore.numberOfPasswords, 0) XCTAssertEqual(passwordStore.numberOfPasswords, 0)
@ -82,6 +87,7 @@ final class PasswordStoreTest: XCTestCase {
XCTAssertFalse(Defaults.hasKey(\.gitSignatureName)) XCTAssertFalse(Defaults.hasKey(\.gitSignatureName))
XCTAssertFalse(PasscodeLock.shared.hasPasscode) XCTAssertFalse(PasscodeLock.shared.hasPasscode)
XCTAssertFalse(PGPAgent.shared.isInitialized()) XCTAssertFalse(PGPAgent.shared.isInitialized())
waitForExpectations(timeout: 1, handler: nil)
} }
func testFetchPasswordEntityCoreDataByParent() throws { func testFetchPasswordEntityCoreDataByParent() throws {
@ -171,8 +177,11 @@ final class PasswordStoreTest: XCTestCase {
} }
private func cloneRepository(_ remote: RemoteRepo) throws { private func cloneRepository(_ remote: RemoteRepo) throws {
try passwordStore.cloneRepository(remoteRepoURL: remote.url, branchName: remote.branchName)
expectation(for: NSPredicate { _, _ in FileManager.default.fileExists(atPath: self.localRepoURL.path) }, evaluatedWith: nil) expectation(for: NSPredicate { _, _ in FileManager.default.fileExists(atPath: self.localRepoURL.path) }, evaluatedWith: nil)
expectation(forNotification: .passwordStoreUpdated, object: nil)
try passwordStore.cloneRepository(remoteRepoURL: remote.url, branchName: remote.branchName)
waitForExpectations(timeout: 3, handler: nil) waitForExpectations(timeout: 3, handler: nil)
} }