|
22 | 22 | #import "Firestore/Example/Tests/Util/FSTHelpers.h" |
23 | 23 | #import "Firestore/Example/Tests/Util/FSTIntegrationTestCase.h" |
24 | 24 |
|
| 25 | +namespace { |
| 26 | + |
| 27 | +NSArray<NSString*>* SortedStringsNotIn(NSSet<NSString*>* set, NSSet<NSString*>* remove) { |
| 28 | + NSMutableSet<NSString*>* mutableSet = [NSMutableSet setWithSet:set]; |
| 29 | + [mutableSet minusSet:remove]; |
| 30 | + return [mutableSet sortedArrayUsingDescriptors:@[[NSSortDescriptor sortDescriptorWithKey:@"description" ascending:YES]]]; |
| 31 | +} |
| 32 | + |
| 33 | +} // namespace |
| 34 | + |
25 | 35 | @interface FIRQueryTests : FSTIntegrationTestCase |
26 | 36 | @end |
27 | 37 |
|
@@ -1240,6 +1250,30 @@ - (void)testResumingAQueryShouldUseExistenceFilterToDetectDeletes { |
1240 | 1250 | // existence filter, resulting in the client including the deleted documents in the snapshot |
1241 | 1251 | // of the resumed query. |
1242 | 1252 | if (!([FSTIntegrationTestCase isRunningAgainstEmulator] && querySnapshot2.count == 100)) { |
| 1253 | + NSSet<NSString*>* actualDocumentIds; |
| 1254 | + { |
| 1255 | + NSMutableSet<NSString*>* actualDocumentIdsAccumulator = [[NSMutableSet alloc] init]; |
| 1256 | + for (FIRDocumentSnapshot* documentSnapshot in querySnapshot2.documents) { |
| 1257 | + [actualDocumentIdsAccumulator addObject:documentSnapshot.documentID]; |
| 1258 | + } |
| 1259 | + actualDocumentIds = [actualDocumentIdsAccumulator copy]; |
| 1260 | + } |
| 1261 | + NSSet<NSString*>* expectedDocumentIds; |
| 1262 | + { |
| 1263 | + NSMutableSet<NSString*>* expectedDocumentIdsAccumulator = [[NSMutableSet alloc] init]; |
| 1264 | + for (FIRDocumentReference* documentRef in createdDocuments) { |
| 1265 | + if (![deletedDocumentIds containsObject:documentRef.documentID]) { |
| 1266 | + [expectedDocumentIdsAccumulator addObject:documentRef.documentID]; |
| 1267 | + } |
| 1268 | + } |
| 1269 | + expectedDocumentIds = [expectedDocumentIdsAccumulator copy]; |
| 1270 | + } |
| 1271 | + if (! [actualDocumentIds isEqualToSet:expectedDocumentIds]) { |
| 1272 | + NSArray<NSString*>* unexpectedDocumentIds = SortedStringsNotIn(actualDocumentIds, expectedDocumentIds); |
| 1273 | + NSArray<NSString*>* missingDocumentIds = SortedStringsNotIn(expectedDocumentIds, actualDocumentIds); |
| 1274 | + (void)unexpectedDocumentIds; |
| 1275 | + (void)missingDocumentIds; |
| 1276 | + } |
1243 | 1277 | } |
1244 | 1278 | } |
1245 | 1279 |
|
|
0 commit comments