@@ -1094,48 +1094,77 @@ class ParseUserTests: XCTestCase { // swiftlint:disable:this type_body_length
1094
1094
return nil
1095
1095
}
1096
1096
}
1097
- do {
1098
- try User . logout ( )
1099
- if let userFromKeychain = BaseParseUser . current {
1100
- XCTFail ( " \( userFromKeychain) wasn't deleted from Keychain during logout " )
1101
- }
1102
1097
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)
1105
1118
}
1106
- } catch {
1107
- XCTFail ( error. localizedDescription)
1108
1119
}
1109
1120
}
1110
1121
1111
1122
func logoutAsync( callbackQueue: DispatchQueue ) {
1112
1123
1113
1124
let expectation1 = XCTestExpectation ( description: " Logout user1 " )
1114
- User . logout ( callbackQueue: callbackQueue) { result in
1115
1125
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
+ }
1117
1132
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
1122
1134
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 {
1127
1136
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
+ }
1134
1150
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 ( )
1137
1167
}
1138
- expectation1. fulfill ( )
1139
1168
}
1140
1169
wait ( for: [ expectation1] , timeout: 20.0 )
1141
1170
}
0 commit comments