diff options
Diffstat (limited to 'Firestore/Example/Tests/Local/FSTQueryCacheTests.mm')
-rw-r--r-- | Firestore/Example/Tests/Local/FSTQueryCacheTests.mm | 53 |
1 files changed, 29 insertions, 24 deletions
diff --git a/Firestore/Example/Tests/Local/FSTQueryCacheTests.mm b/Firestore/Example/Tests/Local/FSTQueryCacheTests.mm index 6ef927d..5dd4b5d 100644 --- a/Firestore/Example/Tests/Local/FSTQueryCacheTests.mm +++ b/Firestore/Example/Tests/Local/FSTQueryCacheTests.mm @@ -22,11 +22,16 @@ #import "Firestore/Source/Local/FSTPersistence.h" #import "Firestore/Source/Local/FSTQueryData.h" #import "Firestore/Source/Local/FSTWriteGroup.h" -#import "Firestore/Source/Model/FSTDocumentKey.h" #import "Firestore/Example/Tests/Util/FSTHelpers.h" #import "Firestore/third_party/Immutable/Tests/FSTImmutableSortedSet+Testing.h" +#include "Firestore/core/src/firebase/firestore/model/document_key.h" +#include "Firestore/core/test/firebase/firestore/testutil/testutil.h" + +namespace testutil = firebase::firestore::testutil; +using firebase::firestore::model::DocumentKey; + NS_ASSUME_NONNULL_BEGIN @implementation FSTQueryCacheTests { @@ -164,8 +169,8 @@ NS_ASSUME_NONNULL_BEGIN FSTQueryData *rooms = [self queryDataWithQuery:_queryRooms]; [self.queryCache addQueryData:rooms group:group]; - FSTDocumentKey *key1 = FSTTestDocKey(@"rooms/foo"); - FSTDocumentKey *key2 = FSTTestDocKey(@"rooms/bar"); + DocumentKey key1 = testutil::Key("rooms/foo"); + DocumentKey key2 = testutil::Key("rooms/bar"); [self addMatchingKey:key1 forTargetID:rooms.targetID group:group]; [self addMatchingKey:key2 forTargetID:rooms.targetID group:group]; @@ -182,7 +187,7 @@ NS_ASSUME_NONNULL_BEGIN if ([self isTestBaseClass]) return; FSTWriteGroup *group = [self.persistence startGroupWithAction:@"AddOrRemoveMatchingKeys"]; - FSTDocumentKey *key = FSTTestDocKey(@"foo/bar"); + DocumentKey key = testutil::Key("foo/bar"); XCTAssertFalse([self.queryCache containsKey:key]); @@ -204,9 +209,9 @@ NS_ASSUME_NONNULL_BEGIN if ([self isTestBaseClass]) return; FSTWriteGroup *group = [self.persistence startGroupWithAction:@"RemoveMatchingKeysForTargetID"]; - FSTDocumentKey *key1 = FSTTestDocKey(@"foo/bar"); - FSTDocumentKey *key2 = FSTTestDocKey(@"foo/baz"); - FSTDocumentKey *key3 = FSTTestDocKey(@"foo/blah"); + DocumentKey key1 = testutil::Key("foo/bar"); + DocumentKey key2 = testutil::Key("foo/baz"); + DocumentKey key3 = testutil::Key("foo/blah"); [self addMatchingKey:key1 forTargetID:1 group:group]; [self addMatchingKey:key2 forTargetID:1 group:group]; @@ -233,32 +238,32 @@ NS_ASSUME_NONNULL_BEGIN FSTWriteGroup *group = [self.persistence startGroupWithAction:@"RemoveEmitsGarbageEvents"]; FSTEagerGarbageCollector *garbageCollector = [[FSTEagerGarbageCollector alloc] init]; [garbageCollector addGarbageSource:self.queryCache]; - FSTAssertEqualSets([garbageCollector collectGarbage], @[]); + XCTAssertEqual([garbageCollector collectGarbage], std::set<DocumentKey>({})); FSTQueryData *rooms = [self queryDataWithQuery:FSTTestQuery("rooms")]; - FSTDocumentKey *room1 = FSTTestDocKey(@"rooms/bar"); - FSTDocumentKey *room2 = FSTTestDocKey(@"rooms/foo"); + DocumentKey room1 = testutil::Key("rooms/bar"); + DocumentKey room2 = testutil::Key("rooms/foo"); [self.queryCache addQueryData:rooms group:group]; [self addMatchingKey:room1 forTargetID:rooms.targetID group:group]; [self addMatchingKey:room2 forTargetID:rooms.targetID group:group]; FSTQueryData *halls = [self queryDataWithQuery:FSTTestQuery("halls")]; - FSTDocumentKey *hall1 = FSTTestDocKey(@"halls/bar"); - FSTDocumentKey *hall2 = FSTTestDocKey(@"halls/foo"); + DocumentKey hall1 = testutil::Key("halls/bar"); + DocumentKey hall2 = testutil::Key("halls/foo"); [self.queryCache addQueryData:halls group:group]; [self addMatchingKey:hall1 forTargetID:halls.targetID group:group]; [self addMatchingKey:hall2 forTargetID:halls.targetID group:group]; - FSTAssertEqualSets([garbageCollector collectGarbage], @[]); + XCTAssertEqual([garbageCollector collectGarbage], std::set<DocumentKey>({})); [self removeMatchingKey:room1 forTargetID:rooms.targetID group:group]; - FSTAssertEqualSets([garbageCollector collectGarbage], @[ room1 ]); + XCTAssertEqual([garbageCollector collectGarbage], std::set<DocumentKey>({room1})); [self.queryCache removeQueryData:rooms group:group]; - FSTAssertEqualSets([garbageCollector collectGarbage], @[ room2 ]); + XCTAssertEqual([garbageCollector collectGarbage], std::set<DocumentKey>({room2})); [self.queryCache removeMatchingKeysForTargetID:halls.targetID group:group]; - FSTAssertEqualSets([garbageCollector collectGarbage], (@[ hall1, hall2 ])); + XCTAssertEqual([garbageCollector collectGarbage], std::set<DocumentKey>({hall1, hall2})); [self.persistence commitGroup:group]; } @@ -266,9 +271,9 @@ NS_ASSUME_NONNULL_BEGIN if ([self isTestBaseClass]) return; FSTWriteGroup *group = [self.persistence startGroupWithAction:@"MatchingKeysForTargetID"]; - FSTDocumentKey *key1 = FSTTestDocKey(@"foo/bar"); - FSTDocumentKey *key2 = FSTTestDocKey(@"foo/baz"); - FSTDocumentKey *key3 = FSTTestDocKey(@"foo/blah"); + DocumentKey key1 = testutil::Key("foo/bar"); + DocumentKey key2 = testutil::Key("foo/baz"); + DocumentKey key3 = testutil::Key("foo/blah"); [self addMatchingKey:key1 forTargetID:1 group:group]; [self addMatchingKey:key2 forTargetID:1 group:group]; @@ -335,8 +340,8 @@ NS_ASSUME_NONNULL_BEGIN targetID:1 listenSequenceNumber:10 purpose:FSTQueryPurposeListen]; - FSTDocumentKey *key1 = FSTTestDocKey(@"rooms/bar"); - FSTDocumentKey *key2 = FSTTestDocKey(@"rooms/foo"); + DocumentKey key1 = testutil::Key("rooms/bar"); + DocumentKey key2 = testutil::Key("rooms/foo"); [self.queryCache addQueryData:query1 group:group]; [self addMatchingKey:key1 forTargetID:1 group:group]; [self addMatchingKey:key2 forTargetID:1 group:group]; @@ -345,7 +350,7 @@ NS_ASSUME_NONNULL_BEGIN targetID:2 listenSequenceNumber:20 purpose:FSTQueryPurposeListen]; - FSTDocumentKey *key3 = FSTTestDocKey(@"halls/foo"); + DocumentKey key3 = testutil::Key("halls/foo"); [self.queryCache addQueryData:query2 group:group]; [self addMatchingKey:key3 forTargetID:2 group:group]; XCTAssertEqual([self.queryCache highestTargetID], 2); @@ -419,7 +424,7 @@ NS_ASSUME_NONNULL_BEGIN resumeToken:resumeToken]; } -- (void)addMatchingKey:(FSTDocumentKey *)key +- (void)addMatchingKey:(cons DocumentKey &)key forTargetID:(FSTTargetID)targetID group:(FSTWriteGroup *)group { FSTDocumentKeySet *keys = [FSTDocumentKeySet keySet]; @@ -427,7 +432,7 @@ NS_ASSUME_NONNULL_BEGIN [self.queryCache addMatchingKeys:keys forTargetID:targetID group:group]; } -- (void)removeMatchingKey:(FSTDocumentKey *)key +- (void)removeMatchingKey:(const DocumentKey &)key forTargetID:(FSTTargetID)targetID group:(FSTWriteGroup *)group { FSTDocumentKeySet *keys = [FSTDocumentKeySet keySet]; |