Skip to content

Commit 608a69f

Browse files
authored
Fix flaky ParseUserCombine test (#145)
* Fix flaky ParseUserCombine test * nit
1 parent f44e2ff commit 608a69f

File tree

1 file changed

+25
-27
lines changed

1 file changed

+25
-27
lines changed

Tests/ParseSwiftTests/ParseUserCombineTests.swift

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -306,37 +306,35 @@ class ParseUserCombineTests: XCTestCase { // swiftlint:disable:this type_body_le
306306
if case let .failure(error) = result {
307307
XCTFail(error.localizedDescription)
308308
}
309-
expectation1.fulfill()
310-
311-
}, receiveValue: { _ in
312-
if let userFromKeychain = BaseParseUser.current {
313-
XCTFail("\(userFromKeychain) wasn't deleted from Keychain during logout")
314-
}
315-
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
316-
if let installationFromMemory: CurrentInstallationContainer<BaseParseInstallation>
317-
= try? ParseStorage.shared.get(valueFor: ParseStorage.Keys.currentInstallation) {
318-
if installationFromMemory.installationId == oldInstallationId
319-
|| installationFromMemory.installationId == nil {
320-
XCTFail("\(installationFromMemory) wasn't deleted and recreated in memory during logout")
321-
}
322-
} else {
323-
XCTFail("Should have a new installation")
309+
if let userFromKeychain = BaseParseUser.current {
310+
XCTFail("\(userFromKeychain) wasn't deleted from Keychain during logout")
324311
}
312+
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
313+
if let installationFromMemory: CurrentInstallationContainer<BaseParseInstallation>
314+
= try? ParseStorage.shared.get(valueFor: ParseStorage.Keys.currentInstallation) {
315+
if installationFromMemory.installationId == oldInstallationId
316+
|| installationFromMemory.installationId == nil {
317+
XCTFail("\(installationFromMemory) wasn't deleted and recreated in memory during logout")
318+
}
319+
} else {
320+
XCTFail("Should have a new installation")
321+
}
325322

326-
#if !os(Linux) && !os(Android)
327-
if let installationFromKeychain: CurrentInstallationContainer<BaseParseInstallation>
328-
= try? KeychainStore.shared.get(valueFor: ParseStorage.Keys.currentInstallation) {
329-
if installationFromKeychain.installationId == oldInstallationId
330-
|| installationFromKeychain.installationId == nil {
331-
XCTFail("\(installationFromKeychain) wasn't deleted & recreated in Keychain during logout")
323+
#if !os(Linux) && !os(Android)
324+
if let installationFromKeychain: CurrentInstallationContainer<BaseParseInstallation>
325+
= try? KeychainStore.shared.get(valueFor: ParseStorage.Keys.currentInstallation) {
326+
if installationFromKeychain.installationId == oldInstallationId
327+
|| installationFromKeychain.installationId == nil {
328+
XCTFail("\(installationFromKeychain) wasn't deleted & recreated in Keychain during logout")
329+
}
330+
} else {
331+
XCTFail("Should have a new installation")
332332
}
333-
} else {
334-
XCTFail("Should have a new installation")
333+
#endif
334+
expectation1.fulfill()
335335
}
336-
#endif
337-
expectation1.fulfill()
338-
}
339-
})
336+
337+
}, receiveValue: { _ in })
340338
publisher.store(in: &subscriptions)
341339
wait(for: [expectation1], timeout: 20.0)
342340
}

0 commit comments

Comments
 (0)