diff options
Diffstat (limited to 'Firestore/Example/Tests/SpecTests')
3 files changed, 27 insertions, 30 deletions
diff --git a/Firestore/Example/Tests/SpecTests/FSTMockDatastore.mm b/Firestore/Example/Tests/SpecTests/FSTMockDatastore.mm index 3c7f46a..63c3d72 100644 --- a/Firestore/Example/Tests/SpecTests/FSTMockDatastore.mm +++ b/Firestore/Example/Tests/SpecTests/FSTMockDatastore.mm @@ -21,7 +21,6 @@ #import "Firestore/Source/Model/FSTMutation.h" #import "Firestore/Source/Remote/FSTSerializerBeta.h" #import "Firestore/Source/Remote/FSTStream.h" -#import "Firestore/Source/Util/FSTAssert.h" #import "Firestore/Example/Tests/Remote/FSTWatchChange+Testing.h" @@ -80,7 +79,7 @@ NS_ASSUME_NONNULL_BEGIN credentials:credentials serializer:serializer]; if (self) { - FSTAssert(datastore, @"Datastore must not be nil"); + HARD_ASSERT(datastore, "Datastore must not be nil"); _datastore = datastore; _activeTargets = [NSMutableDictionary dictionary]; } @@ -90,7 +89,7 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - Overridden FSTWatchStream methods. - (void)startWithDelegate:(id<FSTWatchStreamDelegate>)delegate { - FSTAssert(!self.open, @"Trying to start already started watch stream"); + HARD_ASSERT(!self.open, "Trying to start already started watch stream"); self.open = YES; self.delegate = delegate; [self notifyStreamOpen]; @@ -148,7 +147,7 @@ NS_ASSUME_NONNULL_BEGIN // Technically removing an unknown target is valid (e.g. it could race with a // server-side removal), but we want to pay extra careful attention in tests // that we only remove targets we listened too. - FSTFail(@"Removing a non-active target"); + HARD_FAIL("Removing a non-active target"); } [self.activeTargets removeObjectForKey:targetID]; } @@ -204,7 +203,7 @@ NS_ASSUME_NONNULL_BEGIN credentials:credentials serializer:serializer]; if (self) { - FSTAssert(datastore, @"Datastore must not be nil"); + HARD_ASSERT(datastore, "Datastore must not be nil"); _datastore = datastore; _sentMutations = [NSMutableArray array]; } @@ -214,7 +213,7 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - Overridden FSTWriteStream methods. - (void)startWithDelegate:(id<FSTWriteStreamDelegate>)delegate { - FSTAssert(!self.open, @"Trying to start already started write stream"); + HARD_ASSERT(!self.open, "Trying to start already started write stream"); self.open = YES; [self.sentMutations removeAllObjects]; self.delegate = delegate; @@ -258,8 +257,8 @@ NS_ASSUME_NONNULL_BEGIN * Returns the next write that was "sent to the backend", failing if there are no queued sent */ - (NSArray<FSTMutation *> *)nextSentWrite { - FSTAssert(self.sentMutations.count > 0, - @"Writes need to happen before you can call nextSentWrite."); + HARD_ASSERT(self.sentMutations.count > 0, + "Writes need to happen before you can call nextSentWrite."); NSArray<FSTMutation *> *result = [self.sentMutations objectAtIndex:0]; [self.sentMutations removeObjectAtIndex:0]; return result; @@ -292,7 +291,6 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - Overridden FSTDatastore methods. - (FSTWatchStream *)createWatchStream { - // FSTAssert(self.databaseInfo, @"DatabaseInfo must not be nil"); self.watchStream = [[FSTMockWatchStream alloc] initWithDatastore:self workerDispatchQueue:self.workerDispatchQueue @@ -303,7 +301,6 @@ NS_ASSUME_NONNULL_BEGIN } - (FSTWriteStream *)createWriteStream { - // FSTAssert(self.databaseInfo, @"DatabaseInfo must not be nil"); self.writeStream = [[FSTMockWriteStream alloc] initWithDatastore:self workerDispatchQueue:self.workerDispatchQueue @@ -314,7 +311,7 @@ NS_ASSUME_NONNULL_BEGIN } - (void)authorizeAndStartRPC:(GRPCProtoCall *)rpc completion:(FSTVoidErrorBlock)completion { - FSTFail(@"FSTMockDatastore shouldn't be starting any RPCs."); + HARD_FAIL("FSTMockDatastore shouldn't be starting any RPCs."); } #pragma mark - Method exposed for tests to call. diff --git a/Firestore/Example/Tests/SpecTests/FSTSpecTests.mm b/Firestore/Example/Tests/SpecTests/FSTSpecTests.mm index 7b10bd4..77010e5 100644 --- a/Firestore/Example/Tests/SpecTests/FSTSpecTests.mm +++ b/Firestore/Example/Tests/SpecTests/FSTSpecTests.mm @@ -34,7 +34,6 @@ #import "Firestore/Source/Model/FSTMutation.h" #import "Firestore/Source/Remote/FSTExistenceFilter.h" #import "Firestore/Source/Remote/FSTWatchChange.h" -#import "Firestore/Source/Util/FSTAssert.h" #import "Firestore/Source/Util/FSTClasses.h" #import "Firestore/Source/Util/FSTDispatchQueue.h" @@ -45,6 +44,7 @@ #include "Firestore/core/src/firebase/firestore/auth/user.h" #include "Firestore/core/src/firebase/firestore/model/document_key.h" #include "Firestore/core/src/firebase/firestore/model/snapshot_version.h" +#include "Firestore/core/src/firebase/firestore/util/hard_assert.h" #include "Firestore/core/src/firebase/firestore/util/log.h" #include "Firestore/core/src/firebase/firestore/util/string_apple.h" #include "Firestore/core/test/firebase/firestore/testutil/testutil.h" @@ -233,7 +233,7 @@ static NSString *const kNoIOSTag = @"no-ios"; - (void)doWatchEntity:(NSDictionary *)watchEntity snapshot:(NSNumber *_Nullable)watchSnapshot { if (watchEntity[@"docs"]) { - FSTAssert(!watchEntity[@"doc"], @"Exactly one of |doc| or |docs| needs to be set."); + HARD_ASSERT(!watchEntity[@"doc"], "Exactly one of |doc| or |docs| needs to be set."); int count = 0; NSArray *docs = watchEntity[@"docs"]; for (NSDictionary *doc in docs) { @@ -277,13 +277,13 @@ static NSString *const kNoIOSTag = @"no-ios"; document:nil]; [self.driver receiveWatchChange:change snapshotVersion:[self parseVersion:watchSnapshot]]; } else { - FSTFail(@"Either key, doc or docs must be set."); + HARD_FAIL("Either key, doc or docs must be set."); } } - (void)doWatchFilter:(NSArray *)watchFilter snapshot:(NSNumber *_Nullable)watchSnapshot { NSArray<NSNumber *> *targets = watchFilter[0]; - FSTAssert(targets.count == 1, @"ExistenceFilters currently support exactly one target only."); + HARD_ASSERT(targets.count == 1, "ExistenceFilters currently support exactly one target only."); int keyCount = watchFilter.count == 0 ? 0 : (int)watchFilter.count - 1; @@ -308,7 +308,7 @@ static NSString *const kNoIOSTag = @"no-ios"; NSNumber *runBackoffTimer = closeSpec[@"runBackoffTimer"]; // TODO(b/72313632): Incorporate backoff in iOS Spec Tests. - FSTAssert(runBackoffTimer.boolValue, @"iOS Spec Tests don't support backoff."); + HARD_ASSERT(runBackoffTimer.boolValue, "iOS Spec Tests don't support backoff."); [self.driver receiveWatchStreamError:code userInfo:errorSpec]; } @@ -323,8 +323,8 @@ static NSString *const kNoIOSTag = @"no-ios"; [self.driver receiveWriteAckWithVersion:version mutationResults:@[ mutationResult ]]; if (expectUserCallback.boolValue) { - FSTAssert(write.done, @"Write should be done"); - FSTAssert(!write.error, @"Ack should not fail"); + HARD_ASSERT(write.done, "Write should be done"); + HARD_ASSERT(!write.error, "Ack should not fail"); } } @@ -336,7 +336,7 @@ static NSString *const kNoIOSTag = @"no-ios"; FSTOutstandingWrite *write = [self.driver receiveWriteError:code userInfo:errorSpec]; if (expectUserCallback.boolValue) { - FSTAssert(write.done, @"Write should be done"); + HARD_ASSERT(write.done, "Write should be done"); XCTAssertNotNil(write.error, @"Write should have failed"); XCTAssertEqualObjects(write.error.domain, FIRFirestoreErrorDomain); XCTAssertEqual(write.error.code, code); @@ -358,7 +358,7 @@ static NSString *const kNoIOSTag = @"no-ios"; } else if ([timer isEqualToString:@"online_state_timeout"]) { timerID = FSTTimerIDOnlineStateTimeout; } else { - FSTFail(@"runTimer spec step specified unknown timer: %@", timer); + HARD_FAIL("runTimer spec step specified unknown timer: %s", timer); } [self.driver runTimer:timerID]; @@ -427,7 +427,7 @@ static NSString *const kNoIOSTag = @"no-ios"; [self doWatchStreamClose:step[@"watchStreamClose"]]; } else if (step[@"watchProto"]) { // watchProto isn't yet used, and it's unclear how to create arbitrary protos from JSON. - FSTFail(@"watchProto is not yet supported."); + HARD_FAIL("watchProto is not yet supported."); } else if (step[@"writeAck"]) { [self doWriteAck:step[@"writeAck"]]; } else if (step[@"failWrite"]) { diff --git a/Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.mm b/Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.mm index 40ebfb9..d346197 100644 --- a/Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.mm +++ b/Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.mm @@ -30,7 +30,6 @@ #import "Firestore/Source/Model/FSTMutation.h" #import "Firestore/Source/Remote/FSTDatastore.h" #import "Firestore/Source/Remote/FSTWatchChange.h" -#import "Firestore/Source/Util/FSTAssert.h" #import "Firestore/Example/Tests/Core/FSTSyncEngine+Testing.h" #import "Firestore/Example/Tests/SpecTests/FSTMockDatastore.h" @@ -40,6 +39,7 @@ #include "Firestore/core/src/firebase/firestore/core/database_info.h" #include "Firestore/core/src/firebase/firestore/model/database_id.h" #include "Firestore/core/src/firebase/firestore/model/document_key.h" +#include "Firestore/core/src/firebase/firestore/util/hard_assert.h" #include "Firestore/core/src/firebase/firestore/util/log.h" using firebase::firestore::auth::EmptyCredentialsProvider; @@ -183,9 +183,9 @@ NS_ASSUME_NONNULL_BEGIN - (void)validateUsage { // We could relax this if we found a reason to. - FSTAssert(self.events.count == 0, - @"You must clear all pending events by calling" - " capturedEventsSinceLastCall before calling shutdown."); + HARD_ASSERT(self.events.count == 0, + "You must clear all pending events by calling" + " capturedEventsSinceLastCall before calling shutdown."); } - (void)shutdown { @@ -197,11 +197,11 @@ NS_ASSUME_NONNULL_BEGIN - (void)validateNextWriteSent:(FSTMutation *)expectedWrite { NSArray<FSTMutation *> *request = [self.datastore nextSentWrite]; // Make sure the write went through the pipe like we expected it to. - FSTAssert(request.count == 1, @"Only single mutation requests are supported at the moment"); + HARD_ASSERT(request.count == 1, "Only single mutation requests are supported at the moment"); FSTMutation *actualWrite = request[0]; - FSTAssert([actualWrite isEqual:expectedWrite], - @"Mock datastore received write %@ but first outstanding mutation was %@", actualWrite, - expectedWrite); + HARD_ASSERT([actualWrite isEqual:expectedWrite], + "Mock datastore received write %s but first outstanding mutation was %s", actualWrite, + expectedWrite); LOG_DEBUG("A write was sent: %s", actualWrite); } @@ -347,7 +347,7 @@ NS_ASSUME_NONNULL_BEGIN [self.datastore failWatchStreamWithError:error]; // Unlike web, stream should re-open synchronously (if we have any listeners) if (self.queryListeners.count > 0) { - FSTAssert(self.datastore.isWatchStreamOpen, @"Watch stream is open"); + HARD_ASSERT(self.datastore.isWatchStreamOpen, "Watch stream is open"); } }]; } |