aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Example/Tests/Local/FSTLocalStoreTests.mm
diff options
context:
space:
mode:
Diffstat (limited to 'Firestore/Example/Tests/Local/FSTLocalStoreTests.mm')
-rw-r--r--Firestore/Example/Tests/Local/FSTLocalStoreTests.mm32
1 files changed, 17 insertions, 15 deletions
diff --git a/Firestore/Example/Tests/Local/FSTLocalStoreTests.mm b/Firestore/Example/Tests/Local/FSTLocalStoreTests.mm
index 3565e2e..e10fb12 100644
--- a/Firestore/Example/Tests/Local/FSTLocalStoreTests.mm
+++ b/Firestore/Example/Tests/Local/FSTLocalStoreTests.mm
@@ -41,19 +41,15 @@
#import "Firestore/third_party/Immutable/Tests/FSTImmutableSortedSet+Testing.h"
#include "Firestore/core/src/firebase/firestore/auth/user.h"
+#include "Firestore/core/test/firebase/firestore/testutil/testutil.h"
+namespace testutil = firebase::firestore::testutil;
using firebase::firestore::auth::User;
+using firebase::firestore::model::SnapshotVersion;
+using firebase::firestore::model::DocumentKeySet;
NS_ASSUME_NONNULL_BEGIN
-/** Creates a document version dictionary mapping the document in @a mutation to @a version. */
-FSTDocumentVersionDictionary *FSTVersionDictionary(FSTMutation *mutation,
- FSTTestSnapshotVersion version) {
- FSTDocumentVersionDictionary *result = [FSTDocumentVersionDictionary documentVersionDictionary];
- result = [result dictionaryBySettingObject:FSTTestVersion(version) forKey:mutation.key];
- return result;
-}
-
@interface FSTLocalStoreTests ()
@property(nonatomic, strong, readwrite) id<FSTPersistence> localStorePersistence;
@@ -140,7 +136,7 @@ FSTDocumentVersionDictionary *FSTVersionDictionary(FSTMutation *mutation,
FSTMutationBatch *batch = [self.batches firstObject];
[self.batches removeObjectAtIndex:0];
XCTAssertEqual(batch.mutations.count, 1, @"Acknowledging more than one mutation not supported.");
- FSTSnapshotVersion *version = FSTTestVersion(documentVersion);
+ SnapshotVersion version = testutil::Version(documentVersion);
FSTMutationResult *mutationResult =
[[FSTMutationResult alloc] initWithVersion:version transformResults:nil];
FSTMutationBatchResult *result = [FSTMutationBatchResult resultWithBatch:batch
@@ -227,8 +223,8 @@ FSTDocumentVersionDictionary *FSTVersionDictionary(FSTMutation *mutation,
FSTMutationBatch *batch = [[FSTMutationBatch alloc] initWithBatchID:1
localWriteTime:[FIRTimestamp timestamp]
mutations:@[ set1, set2 ]];
- FSTDocumentKeySet *keys = [batch keys];
- XCTAssertEqual(keys.count, 2);
+ DocumentKeySet keys = [batch keys];
+ XCTAssertEqual(keys.size(), 2u);
}
- (void)testHandlesSetMutation {
@@ -805,6 +801,7 @@ FSTDocumentVersionDictionary *FSTVersionDictionary(FSTMutation *mutation,
FSTQuery *query = FSTTestQuery("foo/bar");
FSTQueryData *queryData = [self.localStore allocateQuery:query];
+ FSTListenSequenceNumber initialSequenceNumber = queryData.sequenceNumber;
FSTBoxedTargetID *targetID = @(queryData.targetID);
NSData *resumeToken = FSTTestResumeTokenFromSnapshotVersion(1000);
@@ -818,7 +815,7 @@ FSTDocumentVersionDictionary *FSTVersionDictionary(FSTMutation *mutation,
NSMutableDictionary<FSTBoxedTargetID *, NSNumber *> *pendingResponses =
[NSMutableDictionary dictionary];
FSTWatchChangeAggregator *aggregator =
- [[FSTWatchChangeAggregator alloc] initWithSnapshotVersion:FSTTestVersion(1000)
+ [[FSTWatchChangeAggregator alloc] initWithSnapshotVersion:testutil::Version(1000)
listenTargets:listens
pendingTargetResponses:pendingResponses];
[aggregator addWatchChanges:@[ watchChange ]];
@@ -831,6 +828,10 @@ FSTDocumentVersionDictionary *FSTVersionDictionary(FSTMutation *mutation,
// Should come back with the same resume token
FSTQueryData *queryData2 = [self.localStore allocateQuery:query];
XCTAssertEqualObjects(queryData2.resumeToken, resumeToken);
+
+ // The sequence number should have been bumped when we saved the new resume token.
+ FSTListenSequenceNumber newSequenceNumber = queryData2.sequenceNumber;
+ XCTAssertGreaterThan(newSequenceNumber, initialSequenceNumber);
}
- (void)testRemoteDocumentKeysForTarget {
@@ -848,13 +849,14 @@ FSTDocumentVersionDictionary *FSTVersionDictionary(FSTMutation *mutation,
[self.localStore locallyWriteMutations:@[ FSTTestSetMutation(@"foo/bonk", @{@"a" : @"b"}) ]];
- FSTDocumentKeySet *keys = [self.localStore remoteDocumentKeysForTarget:2];
- FSTAssertEqualSets(keys, (@[ FSTTestDocKey(@"foo/bar"), FSTTestDocKey(@"foo/baz") ]));
+ DocumentKeySet keys = [self.localStore remoteDocumentKeysForTarget:2];
+ DocumentKeySet expected{testutil::Key("foo/bar"), testutil::Key("foo/baz")};
+ XCTAssertEqual(keys, expected);
[self restartWithNoopGarbageCollector];
keys = [self.localStore remoteDocumentKeysForTarget:2];
- FSTAssertEqualSets(keys, (@[ FSTTestDocKey(@"foo/bar"), FSTTestDocKey(@"foo/baz") ]));
+ XCTAssertEqual(keys, (DocumentKeySet{testutil::Key("foo/bar"), testutil::Key("foo/baz")}));
}
@end