@@ -1094,48 +1094,77 @@ class ParseUserTests: XCTestCase { // swiftlint:disable:this type_body_length
10941094 return nil
10951095 }
10961096 }
1097- do {
1098- try User . logout ( )
1099- if let userFromKeychain = BaseParseUser . current {
1100- XCTFail ( " \( userFromKeychain) wasn't deleted from Keychain during logout " )
1101- }
11021097
1103- if let installationFromKeychain = BaseParseInstallation . current {
1104- XCTFail ( " \( installationFromKeychain) wasn't deleted from Keychain during logout " )
1098+ DispatchQueue . main. async {
1099+ guard let oldInstallationId = BaseParseInstallation . current? . installationId else {
1100+ XCTFail ( " Should have unwrapped " )
1101+ return
1102+ }
1103+ do {
1104+ try User . logout ( )
1105+ if let userFromKeychain = BaseParseUser . current {
1106+ XCTFail ( " \( userFromKeychain) wasn't deleted from Keychain during logout " )
1107+ }
1108+ DispatchQueue . main. async {
1109+ if let installationFromKeychain = BaseParseInstallation . current {
1110+ if installationFromKeychain. installationId == oldInstallationId
1111+ && installationFromKeychain. installationId != nil {
1112+ XCTFail ( " \( installationFromKeychain) wasn't deleted then created in Keychain during logout " )
1113+ }
1114+ }
1115+ }
1116+ } catch {
1117+ XCTFail ( error. localizedDescription)
11051118 }
1106- } catch {
1107- XCTFail ( error. localizedDescription)
11081119 }
11091120 }
11101121
11111122 func logoutAsync( callbackQueue: DispatchQueue ) {
11121123
11131124 let expectation1 = XCTestExpectation ( description: " Logout user1 " )
1114- User . logout ( callbackQueue: callbackQueue) { result in
11151125
1116- switch result {
1126+ DispatchQueue . main. async {
1127+ guard let oldInstallationId = BaseParseInstallation . current? . installationId else {
1128+ XCTFail ( " Should have unwrapped " )
1129+ expectation1. fulfill ( )
1130+ return
1131+ }
11171132
1118- case . success:
1119- if let userFromKeychain = BaseParseUser . current {
1120- XCTFail ( " \( userFromKeychain) wasn't deleted from Keychain during logout " )
1121- }
1133+ User . logout ( callbackQueue: callbackQueue) { result in
11221134
1123- if let installationFromMemory: CurrentInstallationContainer < BaseParseInstallation >
1124- = try ? ParseStorage . shared. get ( valueFor: ParseStorage . Keys. currentInstallation) {
1125- XCTFail ( " \( installationFromMemory) wasn't deleted from memory during logout " )
1126- }
1135+ switch result {
11271136
1128- #if !os(Linux) && !os(Android)
1129- if let installationFromKeychain: CurrentInstallationContainer < BaseParseInstallation >
1130- = try ? KeychainStore . shared. get ( valueFor: ParseStorage . Keys. currentInstallation) {
1131- XCTFail ( " \( installationFromKeychain) wasn't deleted from Keychain during logout " )
1132- }
1133- #endif
1137+ case . success:
1138+ if let userFromKeychain = BaseParseUser . current {
1139+ XCTFail ( " \( userFromKeychain) wasn't deleted from Keychain during logout " )
1140+ }
1141+ DispatchQueue . main. async {
1142+ if let installationFromMemory: CurrentInstallationContainer < BaseParseInstallation >
1143+ = try ? ParseStorage . shared. get ( valueFor: ParseStorage . Keys. currentInstallation) {
1144+ if installationFromMemory. installationId == oldInstallationId
1145+ && installationFromMemory. installationId != nil {
1146+ // swiftlint:disable:next line_length
1147+ XCTFail ( " \( installationFromMemory) wasn't deleted and recreated in memory during logout " )
1148+ }
1149+ }
11341150
1135- case . failure( let error) :
1136- XCTFail ( error. localizedDescription)
1151+ #if !os(Linux) && !os(Android)
1152+ if let installationFromKeychain: CurrentInstallationContainer < BaseParseInstallation >
1153+ = try ? KeychainStore . shared. get ( valueFor: ParseStorage . Keys. currentInstallation) {
1154+ if installationFromKeychain. installationId == oldInstallationId
1155+ && installationFromKeychain. installationId != nil {
1156+ // swiftlint:disable:next line_length
1157+ XCTFail ( " \( installationFromKeychain) wasn't deleted and recreated in Keychain during logout " )
1158+ }
1159+ }
1160+ #endif
1161+ }
1162+
1163+ case . failure( let error) :
1164+ XCTFail ( error. localizedDescription)
1165+ }
1166+ expectation1. fulfill ( )
11371167 }
1138- expectation1. fulfill ( )
11391168 }
11401169 wait ( for: [ expectation1] , timeout: 20.0 )
11411170 }
0 commit comments