@@ -1231,25 +1231,29 @@ - (void)testResumingAQueryShouldUseBloomFilterToAvoidFullRequery {
1231
1231
NSArray <FIRDocumentReference *> *createdDocuments =
1232
1232
FIRDocumentReferenceArrayFromQuerySnapshot (querySnapshot1);
1233
1233
1234
- // Delete 50 of the 100 documents. Do this in a transaction, rather than
1235
- // [FIRDocumentReference deleteDocument], to avoid affecting the local cache.
1234
+ // Delete 50 of the 100 documents. Use a different Firestore instance to avoid affecting the
1235
+ // local cache.
1236
1236
NSSet <NSString *> *deletedDocumentIds;
1237
1237
{
1238
+ FIRFirestore* db2 = [self firestore ];
1239
+ FIRWriteBatch* batch = [db2 batch ];
1240
+
1238
1241
NSMutableArray <NSString *> *deletedDocumentIdsAccumulator = [[NSMutableArray alloc ] init ];
1239
- XCTestExpectation *expectation = [self expectationWithDescription: @" DeleteTransaction" ];
1240
- [collRef.firestore
1241
- runTransactionWithBlock: ^id _Nullable (FIRTransaction *transaction, NSError **) {
1242
- for (decltype (createdDocuments.count ) i = 0 ; i < createdDocuments.count ; i += 2 ) {
1243
- FIRDocumentReference *documentToDelete = createdDocuments[i];
1244
- [transaction deleteDocument: documentToDelete];
1245
- [deletedDocumentIdsAccumulator addObject: documentToDelete.documentID];
1246
- }
1247
- return @" document deletion successful" ;
1248
- }
1249
- completion: ^(id , NSError *) {
1250
- [expectation fulfill ];
1251
- }];
1252
- [self awaitExpectation: expectation];
1242
+ for (decltype (createdDocuments.count ) i = 0 ; i < createdDocuments.count ; i += 2 ) {
1243
+ FIRDocumentReference *documentToDelete = [db2 documentWithPath: createdDocuments[i].path];;
1244
+ [batch deleteDocument: documentToDelete];
1245
+ [deletedDocumentIdsAccumulator addObject: documentToDelete.documentID];
1246
+ }
1247
+
1248
+ XCTestExpectation *commitExpectation = [self expectationWithDescription: @" WriteBatch commit" ];
1249
+ [batch commitWithCompletion: ^(NSError *_Nullable error) {
1250
+ [commitExpectation fulfill ];
1251
+ if (error != nil ) {
1252
+ XCTFail (@" WriteBatch commit failed: %@ " , error);
1253
+ }
1254
+ }];
1255
+ [self awaitExpectation: commitExpectation];
1256
+
1253
1257
deletedDocumentIds = [NSSet setWithArray: deletedDocumentIdsAccumulator];
1254
1258
}
1255
1259
XCTAssertEqual (deletedDocumentIds.count , 50u , @" deletedDocumentIds has the wrong size" );
0 commit comments