@@ -790,12 +790,7 @@ - (void)testCollectionGroupQueries {
790
790
withString: collectionGroup];
791
791
[batch setData: @{@" x" : @1 } forDocument: [self .db documentWithPath: path]];
792
792
}
793
- XCTestExpectation *expectation = [self expectationWithDescription: @" batch written" ];
794
- [batch commitWithCompletion: ^(NSError *error) {
795
- XCTAssertNil (error);
796
- [expectation fulfill ];
797
- }];
798
- [self awaitExpectations ];
793
+ [self commitWriteBatch: batch];
799
794
800
795
FIRQuerySnapshot *querySnapshot =
801
796
[self readDocumentSetForRef: [self .db collectionGroupWithID: collectionGroup]];
@@ -821,12 +816,7 @@ - (void)testCollectionGroupQueriesWithStartAtEndAtWithArbitraryDocumentIDs {
821
816
withString: collectionGroup];
822
817
[batch setData: @{@" x" : @1 } forDocument: [self .db documentWithPath: path]];
823
818
}
824
- XCTestExpectation *expectation = [self expectationWithDescription: @" batch written" ];
825
- [batch commitWithCompletion: ^(NSError *error) {
826
- XCTAssertNil (error);
827
- [expectation fulfill ];
828
- }];
829
- [self awaitExpectations ];
819
+ [self commitWriteBatch: batch];
830
820
831
821
FIRQuerySnapshot *querySnapshot = [self
832
822
readDocumentSetForRef: [[[[self .db collectionGroupWithID: collectionGroup]
@@ -858,12 +848,7 @@ - (void)testCollectionGroupQueriesWithWhereFiltersOnArbitraryDocumentIDs {
858
848
withString: collectionGroup];
859
849
[batch setData: @{@" x" : @1 } forDocument: [self .db documentWithPath: path]];
860
850
}
861
- XCTestExpectation *expectation = [self expectationWithDescription: @" batch written" ];
862
- [batch commitWithCompletion: ^(NSError *error) {
863
- XCTAssertNil (error);
864
- [expectation fulfill ];
865
- }];
866
- [self awaitExpectations ];
851
+ [self commitWriteBatch: batch];
867
852
868
853
FIRQuerySnapshot *querySnapshot = [self
869
854
readDocumentSetForRef: [[[self .db collectionGroupWithID: collectionGroup]
@@ -1231,25 +1216,22 @@ - (void)testResumingAQueryShouldUseBloomFilterToAvoidFullRequery {
1231
1216
NSArray <FIRDocumentReference *> *createdDocuments =
1232
1217
FIRDocumentReferenceArrayFromQuerySnapshot (querySnapshot1);
1233
1218
1234
- // Delete 50 of the 100 documents. Do this in a transaction, rather than
1235
- // [FIRDocumentReference deleteDocument], to avoid affecting the local cache.
1219
+ // Delete 50 of the 100 documents. Use a different Firestore instance to avoid affecting the
1220
+ // local cache.
1236
1221
NSSet <NSString *> *deletedDocumentIds;
1237
1222
{
1223
+ FIRFirestore *db2 = [self firestore ];
1224
+ FIRWriteBatch *batch = [db2 batch ];
1225
+
1238
1226
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];
1227
+ for (decltype (createdDocuments.count ) i = 0 ; i < createdDocuments.count ; i += 2 ) {
1228
+ FIRDocumentReference *documentToDelete = [db2 documentWithPath: createdDocuments[i].path];
1229
+ [batch deleteDocument: documentToDelete];
1230
+ [deletedDocumentIdsAccumulator addObject: documentToDelete.documentID];
1231
+ }
1232
+
1233
+ [self commitWriteBatch: batch];
1234
+
1253
1235
deletedDocumentIds = [NSSet setWithArray: deletedDocumentIdsAccumulator];
1254
1236
}
1255
1237
XCTAssertEqual (deletedDocumentIds.count , 50u , @" deletedDocumentIds has the wrong size" );
0 commit comments