aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm
diff options
context:
space:
mode:
authorGravatar Michael Lehenbauer <mikelehen@gmail.com>2017-12-18 14:21:11 -0800
committerGravatar GitHub <noreply@github.com>2017-12-18 14:21:11 -0800
commit8db0eb618d355c546e8f0894dc1e0799297c5659 (patch)
treee32cf46f60b463c5ab8a6c55b3f3c7a10c71cf7e /Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm
parent27472b5c26763987446114145e22e08a652b6296 (diff)
Test cleanup: Adds a helper for waiting for FSTVoidErrorBlock callbacks.
* Add helper for waiting for FSTVoidErrorBlock callbacks. * Remove errorEventHandler from FSTEventAccumulator.h too. * Add synchronous enableNetwork / disableNetwork helpers. * Workaround for batch writes test flakiness.
Diffstat (limited to 'Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm')
-rw-r--r--Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm39
1 files changed, 17 insertions, 22 deletions
diff --git a/Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm b/Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm
index 3d30a77..839e4a5 100644
--- a/Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm
+++ b/Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm
@@ -18,6 +18,7 @@
#import <FirebaseCore/FIRLogger.h>
#import <FirebaseFirestore/FirebaseFirestore-umbrella.h>
+#import <Firestore/Source/Core/FSTFirestoreClient.h>
#import <GRPCClient/GRPCCall+ChannelArg.h>
#import <GRPCClient/GRPCCall+Tests.h>
@@ -158,11 +159,7 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)shutdownFirestore:(FIRFirestore *)firestore {
- XCTestExpectation *shutdownCompletion = [self expectationWithDescription:@"shutdown"];
- [firestore shutdownWithCompletion:^(NSError *_Nullable error) {
- XCTAssertNil(error);
- [shutdownCompletion fulfill];
- }];
+ [firestore shutdownWithCompletion:[self completionForExpectationWithName:@"shutdown"]];
[self awaitExpectations];
}
@@ -261,31 +258,29 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)writeDocumentRef:(FIRDocumentReference *)ref data:(NSDictionary<NSString *, id> *)data {
- XCTestExpectation *expectation = [self expectationWithDescription:@"setData"];
- [ref setData:data
- completion:^(NSError *_Nullable error) {
- XCTAssertNil(error);
- [expectation fulfill];
- }];
+ [ref setData:data completion:[self completionForExpectationWithName:@"setData"]];
[self awaitExpectations];
}
- (void)updateDocumentRef:(FIRDocumentReference *)ref data:(NSDictionary<id, id> *)data {
- XCTestExpectation *expectation = [self expectationWithDescription:@"updateData"];
- [ref updateData:data
- completion:^(NSError *_Nullable error) {
- XCTAssertNil(error);
- [expectation fulfill];
- }];
+ [ref updateData:data completion:[self completionForExpectationWithName:@"updateData"]];
[self awaitExpectations];
}
- (void)deleteDocumentRef:(FIRDocumentReference *)ref {
- XCTestExpectation *expectation = [self expectationWithDescription:@"deleteDocument"];
- [ref deleteDocumentWithCompletion:^(NSError *_Nullable error) {
- XCTAssertNil(error);
- [expectation fulfill];
- }];
+ [ref deleteDocumentWithCompletion:[self completionForExpectationWithName:@"deleteDocument"]];
+ [self awaitExpectations];
+}
+
+- (void)disableNetwork {
+ [self.db.client
+ disableNetworkWithCompletion:[self completionForExpectationWithName:@"Disable Network."]];
+ [self awaitExpectations];
+}
+
+- (void)enableNetwork {
+ [self.db.client
+ enableNetworkWithCompletion:[self completionForExpectationWithName:@"Enable Network."]];
[self awaitExpectations];
}