diff options
Diffstat (limited to 'Firestore/Example/Tests/Core')
-rw-r--r-- | Firestore/Example/Tests/Core/FSTQueryListenerTests.mm | 48 | ||||
-rw-r--r-- | Firestore/Example/Tests/Core/FSTQueryTests.mm | 148 | ||||
-rw-r--r-- | Firestore/Example/Tests/Core/FSTViewSnapshotTest.mm | 22 | ||||
-rw-r--r-- | Firestore/Example/Tests/Core/FSTViewTests.mm | 150 |
4 files changed, 184 insertions, 184 deletions
diff --git a/Firestore/Example/Tests/Core/FSTQueryListenerTests.mm b/Firestore/Example/Tests/Core/FSTQueryListenerTests.mm index 55c4219..bc253d0 100644 --- a/Firestore/Example/Tests/Core/FSTQueryListenerTests.mm +++ b/Firestore/Example/Tests/Core/FSTQueryListenerTests.mm @@ -46,10 +46,10 @@ NS_ASSUME_NONNULL_BEGIN NSMutableArray<FSTViewSnapshot *> *otherAccum = [NSMutableArray array]; FSTQuery *query = FSTTestQuery("rooms"); - FSTDocument *doc1 = FSTTestDoc(@"rooms/Eros", 1, @{@"name" : @"Eros"}, NO); - FSTDocument *doc2 = FSTTestDoc(@"rooms/Hades", 2, @{@"name" : @"Hades"}, NO); + FSTDocument *doc1 = FSTTestDoc("rooms/Eros", 1, @{@"name" : @"Eros"}, NO); + FSTDocument *doc2 = FSTTestDoc("rooms/Hades", 2, @{@"name" : @"Hades"}, NO); FSTDocument *doc2prime = - FSTTestDoc(@"rooms/Hades", 3, @{@"name" : @"Hades", @"owner" : @"Jonny"}, NO); + FSTTestDoc("rooms/Hades", 3, @{@"name" : @"Hades", @"owner" : @"Jonny"}, NO); FSTQueryListener *listener = [self listenToQuery:query accumulatingSnapshots:accum]; FSTQueryListener *otherListener = [self listenToQuery:query accumulatingSnapshots:otherAccum]; @@ -127,8 +127,8 @@ NS_ASSUME_NONNULL_BEGIN NSMutableArray<FSTViewSnapshot *> *accum = [NSMutableArray array]; FSTQuery *query = FSTTestQuery("rooms/Eros"); - FSTDocument *doc1 = FSTTestDoc(@"rooms/Eros", 3, @{@"name" : @"Eros"}, NO); - FSTDocument *doc2 = FSTTestDoc(@"rooms/Eros", 4, @{@"name" : @"Eros2"}, NO); + FSTDocument *doc1 = FSTTestDoc("rooms/Eros", 3, @{@"name" : @"Eros"}, NO); + FSTDocument *doc2 = FSTTestDoc("rooms/Eros", 4, @{@"name" : @"Eros2"}, NO); __block FSTAsyncQueryListener *listener = [[FSTAsyncQueryListener alloc] initWithDispatchQueue:self.asyncQueue @@ -167,8 +167,8 @@ NS_ASSUME_NONNULL_BEGIN NSMutableArray<FSTViewSnapshot *> *fullAccum = [NSMutableArray array]; FSTQuery *query = FSTTestQuery("rooms"); - FSTDocument *doc1 = FSTTestDoc(@"rooms/Eros", 1, @{@"name" : @"Eros"}, NO); - FSTDocument *doc2 = FSTTestDoc(@"rooms/Hades", 2, @{@"name" : @"Hades"}, NO); + FSTDocument *doc1 = FSTTestDoc("rooms/Eros", 1, @{@"name" : @"Eros"}, NO); + FSTDocument *doc2 = FSTTestDoc("rooms/Hades", 2, @{@"name" : @"Hades"}, NO); FSTListenOptions *options = [[FSTListenOptions alloc] initWithIncludeQueryMetadataChanges:YES includeDocumentMetadataChanges:NO @@ -205,10 +205,10 @@ NS_ASSUME_NONNULL_BEGIN NSMutableArray<FSTViewSnapshot *> *fullAccum = [NSMutableArray array]; FSTQuery *query = FSTTestQuery("rooms"); - FSTDocument *doc1 = FSTTestDoc(@"rooms/Eros", 1, @{@"name" : @"Eros"}, YES); - FSTDocument *doc2 = FSTTestDoc(@"rooms/Hades", 2, @{@"name" : @"Hades"}, NO); - FSTDocument *doc1Prime = FSTTestDoc(@"rooms/Eros", 1, @{@"name" : @"Eros"}, NO); - FSTDocument *doc3 = FSTTestDoc(@"rooms/Other", 3, @{@"name" : @"Other"}, NO); + FSTDocument *doc1 = FSTTestDoc("rooms/Eros", 1, @{@"name" : @"Eros"}, YES); + FSTDocument *doc2 = FSTTestDoc("rooms/Hades", 2, @{@"name" : @"Hades"}, NO); + FSTDocument *doc1Prime = FSTTestDoc("rooms/Eros", 1, @{@"name" : @"Eros"}, NO); + FSTDocument *doc3 = FSTTestDoc("rooms/Other", 3, @{@"name" : @"Other"}, NO); FSTListenOptions *options = [[FSTListenOptions alloc] initWithIncludeQueryMetadataChanges:NO includeDocumentMetadataChanges:YES @@ -254,11 +254,11 @@ NS_ASSUME_NONNULL_BEGIN NSMutableArray<FSTViewSnapshot *> *fullAccum = [NSMutableArray array]; FSTQuery *query = FSTTestQuery("rooms"); - FSTDocument *doc1 = FSTTestDoc(@"rooms/Eros", 1, @{@"name" : @"Eros"}, YES); - FSTDocument *doc2 = FSTTestDoc(@"rooms/Hades", 2, @{@"name" : @"Hades"}, YES); - FSTDocument *doc1Prime = FSTTestDoc(@"rooms/Eros", 1, @{@"name" : @"Eros"}, NO); - FSTDocument *doc2Prime = FSTTestDoc(@"rooms/Hades", 2, @{@"name" : @"Hades"}, NO); - FSTDocument *doc3 = FSTTestDoc(@"rooms/Other", 3, @{@"name" : @"Other"}, NO); + FSTDocument *doc1 = FSTTestDoc("rooms/Eros", 1, @{@"name" : @"Eros"}, YES); + FSTDocument *doc2 = FSTTestDoc("rooms/Hades", 2, @{@"name" : @"Hades"}, YES); + FSTDocument *doc1Prime = FSTTestDoc("rooms/Eros", 1, @{@"name" : @"Eros"}, NO); + FSTDocument *doc2Prime = FSTTestDoc("rooms/Hades", 2, @{@"name" : @"Hades"}, NO); + FSTDocument *doc3 = FSTTestDoc("rooms/Other", 3, @{@"name" : @"Other"}, NO); FSTListenOptions *options = [[FSTListenOptions alloc] initWithIncludeQueryMetadataChanges:YES includeDocumentMetadataChanges:NO @@ -291,10 +291,10 @@ NS_ASSUME_NONNULL_BEGIN NSMutableArray<FSTViewSnapshot *> *filteredAccum = [NSMutableArray array]; FSTQuery *query = FSTTestQuery("rooms"); - FSTDocument *doc1 = FSTTestDoc(@"rooms/Eros", 1, @{@"name" : @"Eros"}, YES); - FSTDocument *doc2 = FSTTestDoc(@"rooms/Hades", 2, @{@"name" : @"Hades"}, NO); - FSTDocument *doc1Prime = FSTTestDoc(@"rooms/Eros", 1, @{@"name" : @"Eros"}, NO); - FSTDocument *doc3 = FSTTestDoc(@"rooms/Other", 3, @{@"name" : @"Other"}, NO); + FSTDocument *doc1 = FSTTestDoc("rooms/Eros", 1, @{@"name" : @"Eros"}, YES); + FSTDocument *doc2 = FSTTestDoc("rooms/Hades", 2, @{@"name" : @"Hades"}, NO); + FSTDocument *doc1Prime = FSTTestDoc("rooms/Eros", 1, @{@"name" : @"Eros"}, NO); + FSTDocument *doc3 = FSTTestDoc("rooms/Other", 3, @{@"name" : @"Other"}, NO); FSTQueryListener *filteredListener = [self listenToQuery:query accumulatingSnapshots:filteredAccum]; @@ -323,8 +323,8 @@ NS_ASSUME_NONNULL_BEGIN NSMutableArray<FSTViewSnapshot *> *events = [NSMutableArray array]; FSTQuery *query = FSTTestQuery("rooms"); - FSTDocument *doc1 = FSTTestDoc(@"rooms/Eros", 1, @{@"name" : @"Eros"}, NO); - FSTDocument *doc2 = FSTTestDoc(@"rooms/Hades", 2, @{@"name" : @"Hades"}, NO); + FSTDocument *doc1 = FSTTestDoc("rooms/Eros", 1, @{@"name" : @"Eros"}, NO); + FSTDocument *doc2 = FSTTestDoc("rooms/Hades", 2, @{@"name" : @"Hades"}, NO); FSTQueryListener *listener = [self listenToQuery:query options:[[FSTListenOptions alloc] initWithIncludeQueryMetadataChanges:NO @@ -366,8 +366,8 @@ NS_ASSUME_NONNULL_BEGIN NSMutableArray<FSTViewSnapshot *> *events = [NSMutableArray array]; FSTQuery *query = FSTTestQuery("rooms"); - FSTDocument *doc1 = FSTTestDoc(@"rooms/Eros", 1, @{@"name" : @"Eros"}, NO); - FSTDocument *doc2 = FSTTestDoc(@"rooms/Hades", 2, @{@"name" : @"Hades"}, NO); + FSTDocument *doc1 = FSTTestDoc("rooms/Eros", 1, @{@"name" : @"Eros"}, NO); + FSTDocument *doc2 = FSTTestDoc("rooms/Hades", 2, @{@"name" : @"Hades"}, NO); FSTQueryListener *listener = [self listenToQuery:query options:[[FSTListenOptions alloc] initWithIncludeQueryMetadataChanges:NO diff --git a/Firestore/Example/Tests/Core/FSTQueryTests.mm b/Firestore/Example/Tests/Core/FSTQueryTests.mm index 8b5b524..02310aa 100644 --- a/Firestore/Example/Tests/Core/FSTQueryTests.mm +++ b/Firestore/Example/Tests/Core/FSTQueryTests.mm @@ -88,9 +88,9 @@ NS_ASSUME_NONNULL_BEGIN } - (void)testMatchesBasedOnDocumentKey { - FSTDocument *doc1 = FSTTestDoc(@"rooms/eros/messages/1", 0, @{@"text" : @"msg1"}, NO); - FSTDocument *doc2 = FSTTestDoc(@"rooms/eros/messages/2", 0, @{@"text" : @"msg2"}, NO); - FSTDocument *doc3 = FSTTestDoc(@"rooms/other/messages/1", 0, @{@"text" : @"msg3"}, NO); + FSTDocument *doc1 = FSTTestDoc("rooms/eros/messages/1", 0, @{@"text" : @"msg1"}, NO); + FSTDocument *doc2 = FSTTestDoc("rooms/eros/messages/2", 0, @{@"text" : @"msg2"}, NO); + FSTDocument *doc3 = FSTTestDoc("rooms/other/messages/1", 0, @{@"text" : @"msg3"}, NO); // document query FSTQuery *query = FSTTestQuery("rooms/eros/messages/1"); @@ -100,10 +100,10 @@ NS_ASSUME_NONNULL_BEGIN } - (void)testMatchesCorrectlyForShallowAncestorQuery { - FSTDocument *doc1 = FSTTestDoc(@"rooms/eros/messages/1", 0, @{@"text" : @"msg1"}, NO); - FSTDocument *doc1Meta = FSTTestDoc(@"rooms/eros/messages/1/meta/1", 0, @{@"meta" : @"mv"}, NO); - FSTDocument *doc2 = FSTTestDoc(@"rooms/eros/messages/2", 0, @{@"text" : @"msg2"}, NO); - FSTDocument *doc3 = FSTTestDoc(@"rooms/other/messages/1", 0, @{@"text" : @"msg3"}, NO); + FSTDocument *doc1 = FSTTestDoc("rooms/eros/messages/1", 0, @{@"text" : @"msg1"}, NO); + FSTDocument *doc1Meta = FSTTestDoc("rooms/eros/messages/1/meta/1", 0, @{@"meta" : @"mv"}, NO); + FSTDocument *doc2 = FSTTestDoc("rooms/eros/messages/2", 0, @{@"text" : @"msg2"}, NO); + FSTDocument *doc3 = FSTTestDoc("rooms/other/messages/1", 0, @{@"text" : @"msg3"}, NO); // shallow ancestor query FSTQuery *query = FSTTestQuery("rooms/eros/messages"); @@ -114,8 +114,8 @@ NS_ASSUME_NONNULL_BEGIN } - (void)testEmptyFieldsAreAllowedForQueries { - FSTDocument *doc1 = FSTTestDoc(@"rooms/eros/messages/1", 0, @{@"text" : @"msg1"}, NO); - FSTDocument *doc2 = FSTTestDoc(@"rooms/eros/messages/2", 0, @{}, NO); + FSTDocument *doc1 = FSTTestDoc("rooms/eros/messages/1", 0, @{@"text" : @"msg1"}, NO); + FSTDocument *doc2 = FSTTestDoc("rooms/eros/messages/2", 0, @{}, NO); FSTQuery *query = [FSTTestQuery("rooms/eros/messages") queryByAddingFilter:FSTTestFilter("text", @"==", @"msg1")]; @@ -129,12 +129,12 @@ NS_ASSUME_NONNULL_BEGIN FSTQuery *query2 = [FSTTestQuery("collection") queryByAddingFilter:FSTTestFilter("sort", @"<=", @(2))]; - FSTDocument *doc1 = FSTTestDoc(@"collection/1", 0, @{ @"sort" : @1 }, NO); - FSTDocument *doc2 = FSTTestDoc(@"collection/2", 0, @{ @"sort" : @2 }, NO); - FSTDocument *doc3 = FSTTestDoc(@"collection/3", 0, @{ @"sort" : @3 }, NO); - FSTDocument *doc4 = FSTTestDoc(@"collection/4", 0, @{ @"sort" : @NO }, NO); - FSTDocument *doc5 = FSTTestDoc(@"collection/5", 0, @{@"sort" : @"string"}, NO); - FSTDocument *doc6 = FSTTestDoc(@"collection/6", 0, @{}, NO); + FSTDocument *doc1 = FSTTestDoc("collection/1", 0, @{ @"sort" : @1 }, NO); + FSTDocument *doc2 = FSTTestDoc("collection/2", 0, @{ @"sort" : @2 }, NO); + FSTDocument *doc3 = FSTTestDoc("collection/3", 0, @{ @"sort" : @3 }, NO); + FSTDocument *doc4 = FSTTestDoc("collection/4", 0, @{ @"sort" : @NO }, NO); + FSTDocument *doc5 = FSTTestDoc("collection/5", 0, @{@"sort" : @"string"}, NO); + FSTDocument *doc6 = FSTTestDoc("collection/6", 0, @{}, NO); XCTAssertFalse([query1 matchesDocument:doc1]); XCTAssertTrue([query1 matchesDocument:doc2]); @@ -154,11 +154,11 @@ NS_ASSUME_NONNULL_BEGIN - (void)testNullFilter { FSTQuery *query = [FSTTestQuery("collection") queryByAddingFilter:FSTTestFilter("sort", @"==", [NSNull null])]; - FSTDocument *doc1 = FSTTestDoc(@"collection/1", 0, @{@"sort" : [NSNull null]}, NO); - FSTDocument *doc2 = FSTTestDoc(@"collection/2", 0, @{ @"sort" : @2 }, NO); - FSTDocument *doc3 = FSTTestDoc(@"collection/2", 0, @{ @"sort" : @3.1 }, NO); - FSTDocument *doc4 = FSTTestDoc(@"collection/4", 0, @{ @"sort" : @NO }, NO); - FSTDocument *doc5 = FSTTestDoc(@"collection/5", 0, @{@"sort" : @"string"}, NO); + FSTDocument *doc1 = FSTTestDoc("collection/1", 0, @{@"sort" : [NSNull null]}, NO); + FSTDocument *doc2 = FSTTestDoc("collection/2", 0, @{ @"sort" : @2 }, NO); + FSTDocument *doc3 = FSTTestDoc("collection/2", 0, @{ @"sort" : @3.1 }, NO); + FSTDocument *doc4 = FSTTestDoc("collection/4", 0, @{ @"sort" : @NO }, NO); + FSTDocument *doc5 = FSTTestDoc("collection/5", 0, @{@"sort" : @"string"}, NO); XCTAssertTrue([query matchesDocument:doc1]); XCTAssertFalse([query matchesDocument:doc2]); @@ -170,11 +170,11 @@ NS_ASSUME_NONNULL_BEGIN - (void)testNanFilter { FSTQuery *query = [FSTTestQuery("collection") queryByAddingFilter:FSTTestFilter("sort", @"==", @(NAN))]; - FSTDocument *doc1 = FSTTestDoc(@"collection/1", 0, @{ @"sort" : @(NAN) }, NO); - FSTDocument *doc2 = FSTTestDoc(@"collection/2", 0, @{ @"sort" : @2 }, NO); - FSTDocument *doc3 = FSTTestDoc(@"collection/2", 0, @{ @"sort" : @3.1 }, NO); - FSTDocument *doc4 = FSTTestDoc(@"collection/4", 0, @{ @"sort" : @NO }, NO); - FSTDocument *doc5 = FSTTestDoc(@"collection/5", 0, @{@"sort" : @"string"}, NO); + FSTDocument *doc1 = FSTTestDoc("collection/1", 0, @{ @"sort" : @(NAN) }, NO); + FSTDocument *doc2 = FSTTestDoc("collection/2", 0, @{ @"sort" : @2 }, NO); + FSTDocument *doc3 = FSTTestDoc("collection/2", 0, @{ @"sort" : @3.1 }, NO); + FSTDocument *doc4 = FSTTestDoc("collection/4", 0, @{ @"sort" : @NO }, NO); + FSTDocument *doc5 = FSTTestDoc("collection/5", 0, @{@"sort" : @"string"}, NO); XCTAssertTrue([query matchesDocument:doc1]); XCTAssertFalse([query matchesDocument:doc2]); @@ -189,13 +189,13 @@ NS_ASSUME_NONNULL_BEGIN FSTQuery *query2 = [FSTTestQuery("collection") queryByAddingFilter:FSTTestFilter("sort", @">=", @(2))]; - FSTDocument *doc1 = FSTTestDoc(@"collection/1", 0, @{ @"sort" : @2 }, NO); - FSTDocument *doc2 = FSTTestDoc(@"collection/2", 0, @{ @"sort" : @[] }, NO); - FSTDocument *doc3 = FSTTestDoc(@"collection/3", 0, @{ @"sort" : @[ @1 ] }, NO); - FSTDocument *doc4 = FSTTestDoc(@"collection/4", 0, @{ @"sort" : @{@"foo" : @2} }, NO); - FSTDocument *doc5 = FSTTestDoc(@"collection/5", 0, @{ @"sort" : @{@"foo" : @"bar"} }, NO); - FSTDocument *doc6 = FSTTestDoc(@"collection/6", 0, @{ @"sort" : @{} }, NO); // no sort field - FSTDocument *doc7 = FSTTestDoc(@"collection/7", 0, @{ @"sort" : @[ @3, @1 ] }, NO); + FSTDocument *doc1 = FSTTestDoc("collection/1", 0, @{ @"sort" : @2 }, NO); + FSTDocument *doc2 = FSTTestDoc("collection/2", 0, @{ @"sort" : @[] }, NO); + FSTDocument *doc3 = FSTTestDoc("collection/3", 0, @{ @"sort" : @[ @1 ] }, NO); + FSTDocument *doc4 = FSTTestDoc("collection/4", 0, @{ @"sort" : @{@"foo" : @2} }, NO); + FSTDocument *doc5 = FSTTestDoc("collection/5", 0, @{ @"sort" : @{@"foo" : @"bar"} }, NO); + FSTDocument *doc6 = FSTTestDoc("collection/6", 0, @{ @"sort" : @{} }, NO); // no sort field + FSTDocument *doc7 = FSTTestDoc("collection/7", 0, @{ @"sort" : @[ @3, @1 ] }, NO); XCTAssertTrue([query1 matchesDocument:doc1]); XCTAssertFalse([query1 matchesDocument:doc2]); @@ -219,12 +219,12 @@ NS_ASSUME_NONNULL_BEGIN queryByAddingSortOrder:[FSTSortOrder sortOrderWithFieldPath:testutil::Field("sort") ascending:YES]]; - FSTDocument *doc1 = FSTTestDoc(@"collection/1", 0, @{ @"sort" : @2 }, NO); - FSTDocument *doc2 = FSTTestDoc(@"collection/2", 0, @{ @"sort" : @[] }, NO); - FSTDocument *doc3 = FSTTestDoc(@"collection/3", 0, @{ @"sort" : @[ @1 ] }, NO); - FSTDocument *doc4 = FSTTestDoc(@"collection/4", 0, @{ @"sort" : @{@"foo" : @2} }, NO); - FSTDocument *doc5 = FSTTestDoc(@"collection/5", 0, @{ @"sort" : @{@"foo" : @"bar"} }, NO); - FSTDocument *doc6 = FSTTestDoc(@"collection/6", 0, @{}, NO); + FSTDocument *doc1 = FSTTestDoc("collection/1", 0, @{ @"sort" : @2 }, NO); + FSTDocument *doc2 = FSTTestDoc("collection/2", 0, @{ @"sort" : @[] }, NO); + FSTDocument *doc3 = FSTTestDoc("collection/3", 0, @{ @"sort" : @[ @1 ] }, NO); + FSTDocument *doc4 = FSTTestDoc("collection/4", 0, @{ @"sort" : @{@"foo" : @2} }, NO); + FSTDocument *doc5 = FSTTestDoc("collection/5", 0, @{ @"sort" : @{@"foo" : @"bar"} }, NO); + FSTDocument *doc6 = FSTTestDoc("collection/6", 0, @{}, NO); XCTAssertTrue([query1 matchesDocument:doc1]); XCTAssertTrue([query1 matchesDocument:doc2]); @@ -236,7 +236,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)testFiltersBasedOnArrayValue { FSTQuery *baseQuery = FSTTestQuery("collection"); - FSTDocument *doc1 = FSTTestDoc(@"collection/doc", 0, @{ @"tags" : @[ @"foo", @1, @YES ] }, NO); + FSTDocument *doc1 = FSTTestDoc("collection/doc", 0, @{ @"tags" : @[ @"foo", @1, @YES ] }, NO); NSArray<id<FSTFilter>> *matchingFilters = @[ FSTTestFilter("tags", @"==", @[ @"foo", @1, @YES ]) ]; @@ -259,7 +259,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)testFiltersBasedOnObjectValue { FSTQuery *baseQuery = FSTTestQuery("collection"); FSTDocument *doc1 = - FSTTestDoc(@"collection/doc", 0, + FSTTestDoc("collection/doc", 0, @{ @"tags" : @{@"foo" : @"foo", @"a" : @0, @"b" : @YES, @"c" : @(NAN)} }, NO); NSArray<id<FSTFilter>> *matchingFilters = @[ @@ -315,20 +315,20 @@ NS_ASSUME_NONNULL_BEGIN // clang-format off NSArray<FSTDocument *> *docs = @[ - FSTTestDoc(@"collection/1", 0, @{@"sort": [NSNull null]}, NO), - FSTTestDoc(@"collection/1", 0, @{@"sort": @NO}, NO), - FSTTestDoc(@"collection/1", 0, @{@"sort": @YES}, NO), - FSTTestDoc(@"collection/1", 0, @{@"sort": @1}, NO), - FSTTestDoc(@"collection/2", 0, @{@"sort": @1}, NO), // by key - FSTTestDoc(@"collection/3", 0, @{@"sort": @1}, NO), // by key - FSTTestDoc(@"collection/1", 0, @{@"sort": @1.9}, NO), - FSTTestDoc(@"collection/1", 0, @{@"sort": @2}, NO), - FSTTestDoc(@"collection/1", 0, @{@"sort": @2.1}, NO), - FSTTestDoc(@"collection/1", 0, @{@"sort": @""}, NO), - FSTTestDoc(@"collection/1", 0, @{@"sort": @"a"}, NO), - FSTTestDoc(@"collection/1", 0, @{@"sort": @"ab"}, NO), - FSTTestDoc(@"collection/1", 0, @{@"sort": @"b"}, NO), - FSTTestDoc(@"collection/1", 0, @{@"sort": + FSTTestDoc("collection/1", 0, @{@"sort": [NSNull null]}, NO), + FSTTestDoc("collection/1", 0, @{@"sort": @NO}, NO), + FSTTestDoc("collection/1", 0, @{@"sort": @YES}, NO), + FSTTestDoc("collection/1", 0, @{@"sort": @1}, NO), + FSTTestDoc("collection/2", 0, @{@"sort": @1}, NO), // by key + FSTTestDoc("collection/3", 0, @{@"sort": @1}, NO), // by key + FSTTestDoc("collection/1", 0, @{@"sort": @1.9}, NO), + FSTTestDoc("collection/1", 0, @{@"sort": @2}, NO), + FSTTestDoc("collection/1", 0, @{@"sort": @2.1}, NO), + FSTTestDoc("collection/1", 0, @{@"sort": @""}, NO), + FSTTestDoc("collection/1", 0, @{@"sort": @"a"}, NO), + FSTTestDoc("collection/1", 0, @{@"sort": @"ab"}, NO), + FSTTestDoc("collection/1", 0, @{@"sort": @"b"}, NO), + FSTTestDoc("collection/1", 0, @{@"sort": FSTTestRef("project", DatabaseId::kDefault, @"collection/id1")}, NO), ]; // clang-format on @@ -347,16 +347,16 @@ NS_ASSUME_NONNULL_BEGIN // clang-format off NSArray<FSTDocument *> *docs = - @[FSTTestDoc(@"collection/1", 0, @{@"sort1": @1, @"sort2": @1}, NO), - FSTTestDoc(@"collection/1", 0, @{@"sort1": @1, @"sort2": @2}, NO), - FSTTestDoc(@"collection/2", 0, @{@"sort1": @1, @"sort2": @2}, NO), // by key - FSTTestDoc(@"collection/3", 0, @{@"sort1": @1, @"sort2": @2}, NO), // by key - FSTTestDoc(@"collection/1", 0, @{@"sort1": @1, @"sort2": @3}, NO), - FSTTestDoc(@"collection/1", 0, @{@"sort1": @2, @"sort2": @1}, NO), - FSTTestDoc(@"collection/1", 0, @{@"sort1": @2, @"sort2": @2}, NO), - FSTTestDoc(@"collection/2", 0, @{@"sort1": @2, @"sort2": @2}, NO), // by key - FSTTestDoc(@"collection/3", 0, @{@"sort1": @2, @"sort2": @2}, NO), // by key - FSTTestDoc(@"collection/1", 0, @{@"sort1": @2, @"sort2": @3}, NO), + @[FSTTestDoc("collection/1", 0, @{@"sort1": @1, @"sort2": @1}, NO), + FSTTestDoc("collection/1", 0, @{@"sort1": @1, @"sort2": @2}, NO), + FSTTestDoc("collection/2", 0, @{@"sort1": @1, @"sort2": @2}, NO), // by key + FSTTestDoc("collection/3", 0, @{@"sort1": @1, @"sort2": @2}, NO), // by key + FSTTestDoc("collection/1", 0, @{@"sort1": @1, @"sort2": @3}, NO), + FSTTestDoc("collection/1", 0, @{@"sort1": @2, @"sort2": @1}, NO), + FSTTestDoc("collection/1", 0, @{@"sort1": @2, @"sort2": @2}, NO), + FSTTestDoc("collection/2", 0, @{@"sort1": @2, @"sort2": @2}, NO), // by key + FSTTestDoc("collection/3", 0, @{@"sort1": @2, @"sort2": @2}, NO), // by key + FSTTestDoc("collection/1", 0, @{@"sort1": @2, @"sort2": @3}, NO), ]; // clang-format on @@ -374,16 +374,16 @@ NS_ASSUME_NONNULL_BEGIN // clang-format off NSArray<FSTDocument *> *docs = - @[FSTTestDoc(@"collection/1", 0, @{@"sort1": @2, @"sort2": @3}, NO), - FSTTestDoc(@"collection/3", 0, @{@"sort1": @2, @"sort2": @2}, NO), - FSTTestDoc(@"collection/2", 0, @{@"sort1": @2, @"sort2": @2}, NO), // by key - FSTTestDoc(@"collection/1", 0, @{@"sort1": @2, @"sort2": @2}, NO), // by key - FSTTestDoc(@"collection/1", 0, @{@"sort1": @2, @"sort2": @1}, NO), - FSTTestDoc(@"collection/1", 0, @{@"sort1": @1, @"sort2": @3}, NO), - FSTTestDoc(@"collection/3", 0, @{@"sort1": @1, @"sort2": @2}, NO), - FSTTestDoc(@"collection/2", 0, @{@"sort1": @1, @"sort2": @2}, NO), // by key - FSTTestDoc(@"collection/1", 0, @{@"sort1": @1, @"sort2": @2}, NO), // by key - FSTTestDoc(@"collection/1", 0, @{@"sort1": @1, @"sort2": @1}, NO), + @[FSTTestDoc("collection/1", 0, @{@"sort1": @2, @"sort2": @3}, NO), + FSTTestDoc("collection/3", 0, @{@"sort1": @2, @"sort2": @2}, NO), + FSTTestDoc("collection/2", 0, @{@"sort1": @2, @"sort2": @2}, NO), // by key + FSTTestDoc("collection/1", 0, @{@"sort1": @2, @"sort2": @2}, NO), // by key + FSTTestDoc("collection/1", 0, @{@"sort1": @2, @"sort2": @1}, NO), + FSTTestDoc("collection/1", 0, @{@"sort1": @1, @"sort2": @3}, NO), + FSTTestDoc("collection/3", 0, @{@"sort1": @1, @"sort2": @2}, NO), + FSTTestDoc("collection/2", 0, @{@"sort1": @1, @"sort2": @2}, NO), // by key + FSTTestDoc("collection/1", 0, @{@"sort1": @1, @"sort2": @2}, NO), // by key + FSTTestDoc("collection/1", 0, @{@"sort1": @1, @"sort2": @1}, NO), ]; // clang-format on diff --git a/Firestore/Example/Tests/Core/FSTViewSnapshotTest.mm b/Firestore/Example/Tests/Core/FSTViewSnapshotTest.mm index c503684..ca8954e 100644 --- a/Firestore/Example/Tests/Core/FSTViewSnapshotTest.mm +++ b/Firestore/Example/Tests/Core/FSTViewSnapshotTest.mm @@ -32,7 +32,7 @@ NS_ASSUME_NONNULL_BEGIN @implementation FSTViewSnapshotTests - (void)testDocumentChangeConstructor { - FSTDocument *doc = FSTTestDoc(@"a/b", 0, @{}, NO); + FSTDocument *doc = FSTTestDoc("a/b", 0, @{}, NO); FSTDocumentViewChangeType type = FSTDocumentViewChangeTypeModified; FSTDocumentViewChange *change = [FSTDocumentViewChange changeWithDocument:doc type:type]; XCTAssertEqual(change.document, doc); @@ -42,15 +42,15 @@ NS_ASSUME_NONNULL_BEGIN - (void)testTrack { FSTDocumentViewChangeSet *set = [FSTDocumentViewChangeSet changeSet]; - FSTDocument *docAdded = FSTTestDoc(@"a/1", 0, @{}, NO); - FSTDocument *docRemoved = FSTTestDoc(@"a/2", 0, @{}, NO); - FSTDocument *docModified = FSTTestDoc(@"a/3", 0, @{}, NO); + FSTDocument *docAdded = FSTTestDoc("a/1", 0, @{}, NO); + FSTDocument *docRemoved = FSTTestDoc("a/2", 0, @{}, NO); + FSTDocument *docModified = FSTTestDoc("a/3", 0, @{}, NO); - FSTDocument *docAddedThenModified = FSTTestDoc(@"b/1", 0, @{}, NO); - FSTDocument *docAddedThenRemoved = FSTTestDoc(@"b/2", 0, @{}, NO); - FSTDocument *docRemovedThenAdded = FSTTestDoc(@"b/3", 0, @{}, NO); - FSTDocument *docModifiedThenRemoved = FSTTestDoc(@"b/4", 0, @{}, NO); - FSTDocument *docModifiedThenModified = FSTTestDoc(@"b/5", 0, @{}, NO); + FSTDocument *docAddedThenModified = FSTTestDoc("b/1", 0, @{}, NO); + FSTDocument *docAddedThenRemoved = FSTTestDoc("b/2", 0, @{}, NO); + FSTDocument *docRemovedThenAdded = FSTTestDoc("b/3", 0, @{}, NO); + FSTDocument *docModifiedThenRemoved = FSTTestDoc("b/4", 0, @{}, NO); + FSTDocument *docModifiedThenModified = FSTTestDoc("b/5", 0, @{}, NO); [set addChange:[FSTDocumentViewChange changeWithDocument:docAdded type:FSTDocumentViewChangeTypeAdded]]; @@ -109,9 +109,9 @@ NS_ASSUME_NONNULL_BEGIN FSTQuery *query = FSTTestQuery("a"); FSTDocumentSet *documents = [FSTDocumentSet documentSetWithComparator:FSTDocumentComparatorByKey]; FSTDocumentSet *oldDocuments = documents; - documents = [documents documentSetByAddingDocument:FSTTestDoc(@"c/a", 1, @{}, NO)]; + documents = [documents documentSetByAddingDocument:FSTTestDoc("c/a", 1, @{}, NO)]; NSArray<FSTDocumentViewChange *> *documentChanges = - @[ [FSTDocumentViewChange changeWithDocument:FSTTestDoc(@"c/a", 1, @{}, NO) + @[ [FSTDocumentViewChange changeWithDocument:FSTTestDoc("c/a", 1, @{}, NO) type:FSTDocumentViewChangeTypeAdded] ]; BOOL fromCache = YES; diff --git a/Firestore/Example/Tests/Core/FSTViewTests.mm b/Firestore/Example/Tests/Core/FSTViewTests.mm index 1e3ec1a..63ce711 100644 --- a/Firestore/Example/Tests/Core/FSTViewTests.mm +++ b/Firestore/Example/Tests/Core/FSTViewTests.mm @@ -51,9 +51,9 @@ NS_ASSUME_NONNULL_BEGIN FSTQuery *query = [self queryForMessages]; FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:[FSTDocumentKeySet keySet]]; - FSTDocument *doc1 = FSTTestDoc(@"rooms/eros/messages/1", 0, @{@"text" : @"msg1"}, NO); - FSTDocument *doc2 = FSTTestDoc(@"rooms/eros/messages/2", 0, @{@"text" : @"msg2"}, NO); - FSTDocument *doc3 = FSTTestDoc(@"rooms/other/messages/1", 0, @{@"text" : @"msg3"}, NO); + FSTDocument *doc1 = FSTTestDoc("rooms/eros/messages/1", 0, @{@"text" : @"msg1"}, NO); + FSTDocument *doc2 = FSTTestDoc("rooms/eros/messages/2", 0, @{@"text" : @"msg2"}, NO); + FSTDocument *doc3 = FSTTestDoc("rooms/other/messages/1", 0, @{@"text" : @"msg3"}, NO); FSTViewSnapshot *_Nullable snapshot = FSTTestApplyChanges(view, @[ doc1, doc2, doc3 ], @@ -79,16 +79,16 @@ NS_ASSUME_NONNULL_BEGIN FSTQuery *query = [self queryForMessages]; FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:[FSTDocumentKeySet keySet]]; - FSTDocument *doc1 = FSTTestDoc(@"rooms/eros/messages/1", 0, @{@"text" : @"msg1"}, NO); - FSTDocument *doc2 = FSTTestDoc(@"rooms/eros/messages/2", 0, @{@"text" : @"msg2"}, NO); - FSTDocument *doc3 = FSTTestDoc(@"rooms/eros/messages/3", 0, @{@"text" : @"msg3"}, NO); + FSTDocument *doc1 = FSTTestDoc("rooms/eros/messages/1", 0, @{@"text" : @"msg1"}, NO); + FSTDocument *doc2 = FSTTestDoc("rooms/eros/messages/2", 0, @{@"text" : @"msg2"}, NO); + FSTDocument *doc3 = FSTTestDoc("rooms/eros/messages/3", 0, @{@"text" : @"msg3"}, NO); // initial state FSTTestApplyChanges(view, @[ doc1, doc2 ], nil); // delete doc2, add doc3 FSTViewSnapshot *snapshot = - FSTTestApplyChanges(view, @[ FSTTestDeletedDoc(@"rooms/eros/messages/2", 0), doc3 ], + FSTTestApplyChanges(view, @[ FSTTestDeletedDoc("rooms/eros/messages/2", 0), doc3 ], [FSTTargetChange changeWithDocuments:@[ doc1, doc3 ] currentStatusUpdate:FSTCurrentStatusUpdateMarkCurrent]); @@ -110,8 +110,8 @@ NS_ASSUME_NONNULL_BEGIN FSTQuery *query = [self queryForMessages]; FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:[FSTDocumentKeySet keySet]]; - FSTDocument *doc1 = FSTTestDoc(@"rooms/eros/messages/1", 0, @{@"text" : @"msg1"}, NO); - FSTDocument *doc2 = FSTTestDoc(@"rooms/eros/messages/2", 0, @{@"text" : @"msg2"}, NO); + FSTDocument *doc1 = FSTTestDoc("rooms/eros/messages/1", 0, @{@"text" : @"msg1"}, NO); + FSTDocument *doc2 = FSTTestDoc("rooms/eros/messages/2", 0, @{@"text" : @"msg2"}, NO); // initial state FSTTestApplyChanges(view, @[ doc1, doc2 ], nil); @@ -138,11 +138,11 @@ NS_ASSUME_NONNULL_BEGIN query = [query queryByAddingFilter:filter]; FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:[FSTDocumentKeySet keySet]]; - FSTDocument *doc1 = FSTTestDoc(@"rooms/eros/messages/1", 0, @{ @"sort" : @1 }, NO); - FSTDocument *doc2 = FSTTestDoc(@"rooms/eros/messages/2", 0, @{ @"sort" : @2 }, NO); - FSTDocument *doc3 = FSTTestDoc(@"rooms/eros/messages/3", 0, @{ @"sort" : @3 }, NO); - FSTDocument *doc4 = FSTTestDoc(@"rooms/eros/messages/4", 0, @{}, NO); // no sort, no match - FSTDocument *doc5 = FSTTestDoc(@"rooms/eros/messages/5", 0, @{ @"sort" : @1 }, NO); + FSTDocument *doc1 = FSTTestDoc("rooms/eros/messages/1", 0, @{ @"sort" : @1 }, NO); + FSTDocument *doc2 = FSTTestDoc("rooms/eros/messages/2", 0, @{ @"sort" : @2 }, NO); + FSTDocument *doc3 = FSTTestDoc("rooms/eros/messages/3", 0, @{ @"sort" : @3 }, NO); + FSTDocument *doc4 = FSTTestDoc("rooms/eros/messages/4", 0, @{}, NO); // no sort, no match + FSTDocument *doc5 = FSTTestDoc("rooms/eros/messages/5", 0, @{ @"sort" : @1 }, NO); FSTViewSnapshot *snapshot = FSTTestApplyChanges(view, @[ doc1, doc2, doc3, doc4, doc5 ], nil); @@ -170,10 +170,10 @@ NS_ASSUME_NONNULL_BEGIN query = [query queryByAddingFilter:filter]; FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:[FSTDocumentKeySet keySet]]; - FSTDocument *doc1 = FSTTestDoc(@"rooms/eros/messages/1", 0, @{ @"sort" : @1 }, NO); - FSTDocument *doc2 = FSTTestDoc(@"rooms/eros/messages/2", 0, @{ @"sort" : @3 }, NO); - FSTDocument *doc3 = FSTTestDoc(@"rooms/eros/messages/3", 0, @{ @"sort" : @2 }, NO); - FSTDocument *doc4 = FSTTestDoc(@"rooms/eros/messages/4", 0, @{}, NO); + FSTDocument *doc1 = FSTTestDoc("rooms/eros/messages/1", 0, @{ @"sort" : @1 }, NO); + FSTDocument *doc2 = FSTTestDoc("rooms/eros/messages/2", 0, @{ @"sort" : @3 }, NO); + FSTDocument *doc3 = FSTTestDoc("rooms/eros/messages/3", 0, @{ @"sort" : @2 }, NO); + FSTDocument *doc4 = FSTTestDoc("rooms/eros/messages/4", 0, @{}, NO); FSTViewSnapshot *snapshot = FSTTestApplyChanges(view, @[ doc1, doc2, doc3, doc4 ], nil); @@ -181,9 +181,9 @@ NS_ASSUME_NONNULL_BEGIN XCTAssertEqualObjects(snapshot.documents.arrayValue, (@[ doc1, doc3 ])); - FSTDocument *newDoc2 = FSTTestDoc(@"rooms/eros/messages/2", 1, @{ @"sort" : @2 }, NO); - FSTDocument *newDoc3 = FSTTestDoc(@"rooms/eros/messages/3", 1, @{ @"sort" : @3 }, NO); - FSTDocument *newDoc4 = FSTTestDoc(@"rooms/eros/messages/4", 1, @{ @"sort" : @0 }, NO); + FSTDocument *newDoc2 = FSTTestDoc("rooms/eros/messages/2", 1, @{ @"sort" : @2 }, NO); + FSTDocument *newDoc3 = FSTTestDoc("rooms/eros/messages/3", 1, @{ @"sort" : @3 }, NO); + FSTDocument *newDoc4 = FSTTestDoc("rooms/eros/messages/4", 1, @{ @"sort" : @0 }, NO); snapshot = FSTTestApplyChanges(view, @[ newDoc2, newDoc3, newDoc4 ], nil); @@ -207,9 +207,9 @@ NS_ASSUME_NONNULL_BEGIN query = [query queryBySettingLimit:2]; FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:[FSTDocumentKeySet keySet]]; - FSTDocument *doc1 = FSTTestDoc(@"rooms/eros/messages/1", 0, @{@"text" : @"msg1"}, NO); - FSTDocument *doc2 = FSTTestDoc(@"rooms/eros/messages/2", 0, @{@"text" : @"msg2"}, NO); - FSTDocument *doc3 = FSTTestDoc(@"rooms/eros/messages/3", 0, @{@"text" : @"msg3"}, NO); + FSTDocument *doc1 = FSTTestDoc("rooms/eros/messages/1", 0, @{@"text" : @"msg1"}, NO); + FSTDocument *doc2 = FSTTestDoc("rooms/eros/messages/2", 0, @{@"text" : @"msg2"}, NO); + FSTDocument *doc3 = FSTTestDoc("rooms/eros/messages/3", 0, @{@"text" : @"msg3"}, NO); // initial state FSTTestApplyChanges(view, @[ doc1, doc3 ], nil); @@ -241,10 +241,10 @@ NS_ASSUME_NONNULL_BEGIN query = [query queryBySettingLimit:2]; FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:[FSTDocumentKeySet keySet]]; - FSTDocument *doc1 = FSTTestDoc(@"rooms/eros/messages/1", 0, @{ @"num" : @1 }, NO); - FSTDocument *doc2 = FSTTestDoc(@"rooms/eros/messages/2", 0, @{ @"num" : @2 }, NO); - FSTDocument *doc3 = FSTTestDoc(@"rooms/eros/messages/3", 0, @{ @"num" : @3 }, NO); - FSTDocument *doc4 = FSTTestDoc(@"rooms/eros/messages/4", 0, @{ @"num" : @4 }, NO); + FSTDocument *doc1 = FSTTestDoc("rooms/eros/messages/1", 0, @{ @"num" : @1 }, NO); + FSTDocument *doc2 = FSTTestDoc("rooms/eros/messages/2", 0, @{ @"num" : @2 }, NO); + FSTDocument *doc3 = FSTTestDoc("rooms/eros/messages/3", 0, @{ @"num" : @3 }, NO); + FSTDocument *doc4 = FSTTestDoc("rooms/eros/messages/4", 0, @{ @"num" : @4 }, NO); // initial state FSTTestApplyChanges(view, @[ doc1, doc2 ], nil); @@ -253,7 +253,7 @@ NS_ASSUME_NONNULL_BEGIN // doc2 will be modified + removed = removed // doc3 will be added // doc4 will be added + removed = nothing - doc2 = FSTTestDoc(@"rooms/eros/messages/2", 1, @{ @"num" : @5 }, NO); + doc2 = FSTTestDoc("rooms/eros/messages/2", 1, @{ @"num" : @5 }, NO); FSTViewDocumentChanges *viewDocChanges = [view computeChangesWithDocuments:FSTTestDocUpdates(@[ doc2, doc3, doc4 ])]; XCTAssertTrue(viewDocChanges.needsRefill); @@ -285,9 +285,9 @@ NS_ASSUME_NONNULL_BEGIN FSTQuery *query = [self queryForMessages]; FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:[FSTDocumentKeySet keySet]]; - FSTDocument *doc1 = FSTTestDoc(@"rooms/eros/messages/0", 0, @{}, NO); - FSTDocument *doc2 = FSTTestDoc(@"rooms/eros/messages/1", 0, @{}, NO); - FSTDocument *doc3 = FSTTestDoc(@"rooms/eros/messages/2", 0, @{}, NO); + FSTDocument *doc1 = FSTTestDoc("rooms/eros/messages/0", 0, @{}, NO); + FSTDocument *doc2 = FSTTestDoc("rooms/eros/messages/1", 0, @{}, NO); + FSTDocument *doc3 = FSTTestDoc("rooms/eros/messages/2", 0, @{}, NO); FSTViewChange *change = [view applyChangesToDocuments:[view computeChangesWithDocuments:FSTTestDocUpdates(@[ doc1 ])]]; @@ -323,7 +323,7 @@ NS_ASSUME_NONNULL_BEGIN @[ [FSTLimboDocumentChange changeWithType:FSTLimboDocumentChangeTypeAdded key:doc3.key] ]); change = [view applyChangesToDocuments:[view computeChangesWithDocuments:FSTTestDocUpdates(@[ - FSTTestDeletedDoc(@"rooms/eros/messages/2", + FSTTestDeletedDoc("rooms/eros/messages/2", 1) ])]]; // remove XCTAssertEqualObjects( @@ -334,8 +334,8 @@ NS_ASSUME_NONNULL_BEGIN - (void)testResumingQueryCreatesNoLimbos { FSTQuery *query = [self queryForMessages]; - FSTDocument *doc1 = FSTTestDoc(@"rooms/eros/messages/0", 0, @{}, NO); - FSTDocument *doc2 = FSTTestDoc(@"rooms/eros/messages/1", 0, @{}, NO); + FSTDocument *doc1 = FSTTestDoc("rooms/eros/messages/0", 0, @{}, NO); + FSTDocument *doc2 = FSTTestDoc("rooms/eros/messages/1", 0, @{}, NO); // Unlike other cases, here the view is initialized with a set of previously synced documents // which happens when listening to a previously listened-to query. @@ -359,8 +359,8 @@ NS_ASSUME_NONNULL_BEGIN - (void)testReturnsNeedsRefillOnDeleteInLimitQuery { FSTQuery *query = [[self queryForMessages] queryBySettingLimit:2]; - FSTDocument *doc1 = FSTTestDoc(@"rooms/eros/messages/0", 0, @{}, NO); - FSTDocument *doc2 = FSTTestDoc(@"rooms/eros/messages/1", 0, @{}, NO); + FSTDocument *doc1 = FSTTestDoc("rooms/eros/messages/0", 0, @{}, NO); + FSTDocument *doc2 = FSTTestDoc("rooms/eros/messages/1", 0, @{}, NO); FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:[FSTDocumentKeySet keySet]]; // Start with a full view. @@ -373,7 +373,7 @@ NS_ASSUME_NONNULL_BEGIN // Remove one of the docs. changes = [view computeChangesWithDocuments:FSTTestDocUpdates(@[ FSTTestDeletedDoc( - @"rooms/eros/messages/0", 0) ])]; + "rooms/eros/messages/0", 0) ])]; [self assertDocSet:changes.documentSet containsDocs:@[ doc2 ]]; XCTAssertTrue(changes.needsRefill); XCTAssertEqual(1, [changes.changeSet changes].count); @@ -391,9 +391,9 @@ NS_ASSUME_NONNULL_BEGIN [query queryByAddingSortOrder:[FSTSortOrder sortOrderWithFieldPath:testutil::Field("order") ascending:YES]]; query = [query queryBySettingLimit:2]; - FSTDocument *doc1 = FSTTestDoc(@"rooms/eros/messages/0", 0, @{ @"order" : @1 }, NO); - FSTDocument *doc2 = FSTTestDoc(@"rooms/eros/messages/1", 0, @{ @"order" : @2 }, NO); - FSTDocument *doc3 = FSTTestDoc(@"rooms/eros/messages/2", 0, @{ @"order" : @3 }, NO); + FSTDocument *doc1 = FSTTestDoc("rooms/eros/messages/0", 0, @{ @"order" : @1 }, NO); + FSTDocument *doc2 = FSTTestDoc("rooms/eros/messages/1", 0, @{ @"order" : @2 }, NO); + FSTDocument *doc3 = FSTTestDoc("rooms/eros/messages/2", 0, @{ @"order" : @3 }, NO); FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:[FSTDocumentKeySet keySet]]; // Start with a full view. @@ -405,7 +405,7 @@ NS_ASSUME_NONNULL_BEGIN [view applyChangesToDocuments:changes]; // Move one of the docs. - doc2 = FSTTestDoc(@"rooms/eros/messages/1", 1, @{ @"order" : @2000 }, NO); + doc2 = FSTTestDoc("rooms/eros/messages/1", 1, @{ @"order" : @2000 }, NO); changes = [view computeChangesWithDocuments:FSTTestDocUpdates(@[ doc2 ])]; [self assertDocSet:changes.documentSet containsDocs:@[ doc1, doc2 ]]; XCTAssertTrue(changes.needsRefill); @@ -425,11 +425,11 @@ NS_ASSUME_NONNULL_BEGIN [query queryByAddingSortOrder:[FSTSortOrder sortOrderWithFieldPath:testutil::Field("order") ascending:YES]]; query = [query queryBySettingLimit:3]; - FSTDocument *doc1 = FSTTestDoc(@"rooms/eros/messages/0", 0, @{ @"order" : @1 }, NO); - FSTDocument *doc2 = FSTTestDoc(@"rooms/eros/messages/1", 0, @{ @"order" : @2 }, NO); - FSTDocument *doc3 = FSTTestDoc(@"rooms/eros/messages/2", 0, @{ @"order" : @3 }, NO); - FSTDocument *doc4 = FSTTestDoc(@"rooms/eros/messages/3", 0, @{ @"order" : @4 }, NO); - FSTDocument *doc5 = FSTTestDoc(@"rooms/eros/messages/4", 0, @{ @"order" : @5 }, NO); + FSTDocument *doc1 = FSTTestDoc("rooms/eros/messages/0", 0, @{ @"order" : @1 }, NO); + FSTDocument *doc2 = FSTTestDoc("rooms/eros/messages/1", 0, @{ @"order" : @2 }, NO); + FSTDocument *doc3 = FSTTestDoc("rooms/eros/messages/2", 0, @{ @"order" : @3 }, NO); + FSTDocument *doc4 = FSTTestDoc("rooms/eros/messages/3", 0, @{ @"order" : @4 }, NO); + FSTDocument *doc5 = FSTTestDoc("rooms/eros/messages/4", 0, @{ @"order" : @5 }, NO); FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:[FSTDocumentKeySet keySet]]; // Start with a full view. @@ -441,7 +441,7 @@ NS_ASSUME_NONNULL_BEGIN [view applyChangesToDocuments:changes]; // Move one of the docs. - doc1 = FSTTestDoc(@"rooms/eros/messages/0", 1, @{ @"order" : @3 }, NO); + doc1 = FSTTestDoc("rooms/eros/messages/0", 1, @{ @"order" : @3 }, NO); changes = [view computeChangesWithDocuments:FSTTestDocUpdates(@[ doc1 ])]; [self assertDocSet:changes.documentSet containsDocs:@[ doc2, doc3, doc1 ]]; XCTAssertFalse(changes.needsRefill); @@ -455,11 +455,11 @@ NS_ASSUME_NONNULL_BEGIN [query queryByAddingSortOrder:[FSTSortOrder sortOrderWithFieldPath:testutil::Field("order") ascending:YES]]; query = [query queryBySettingLimit:3]; - FSTDocument *doc1 = FSTTestDoc(@"rooms/eros/messages/0", 0, @{ @"order" : @1 }, NO); - FSTDocument *doc2 = FSTTestDoc(@"rooms/eros/messages/1", 0, @{ @"order" : @2 }, NO); - FSTDocument *doc3 = FSTTestDoc(@"rooms/eros/messages/2", 0, @{ @"order" : @3 }, NO); - FSTDocument *doc4 = FSTTestDoc(@"rooms/eros/messages/3", 0, @{ @"order" : @4 }, NO); - FSTDocument *doc5 = FSTTestDoc(@"rooms/eros/messages/4", 0, @{ @"order" : @5 }, NO); + FSTDocument *doc1 = FSTTestDoc("rooms/eros/messages/0", 0, @{ @"order" : @1 }, NO); + FSTDocument *doc2 = FSTTestDoc("rooms/eros/messages/1", 0, @{ @"order" : @2 }, NO); + FSTDocument *doc3 = FSTTestDoc("rooms/eros/messages/2", 0, @{ @"order" : @3 }, NO); + FSTDocument *doc4 = FSTTestDoc("rooms/eros/messages/3", 0, @{ @"order" : @4 }, NO); + FSTDocument *doc5 = FSTTestDoc("rooms/eros/messages/4", 0, @{ @"order" : @5 }, NO); FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:[FSTDocumentKeySet keySet]]; // Start with a full view. @@ -471,7 +471,7 @@ NS_ASSUME_NONNULL_BEGIN [view applyChangesToDocuments:changes]; // Move one of the docs. - doc4 = FSTTestDoc(@"rooms/eros/messages/3", 1, @{ @"order" : @6 }, NO); + doc4 = FSTTestDoc("rooms/eros/messages/3", 1, @{ @"order" : @6 }, NO); changes = [view computeChangesWithDocuments:FSTTestDocUpdates(@[ doc4 ])]; [self assertDocSet:changes.documentSet containsDocs:@[ doc1, doc2, doc3 ]]; XCTAssertFalse(changes.needsRefill); @@ -481,8 +481,8 @@ NS_ASSUME_NONNULL_BEGIN - (void)testDoesntNeedRefillForAdditionAfterTheLimit { FSTQuery *query = [[self queryForMessages] queryBySettingLimit:2]; - FSTDocument *doc1 = FSTTestDoc(@"rooms/eros/messages/0", 0, @{}, NO); - FSTDocument *doc2 = FSTTestDoc(@"rooms/eros/messages/1", 0, @{}, NO); + FSTDocument *doc1 = FSTTestDoc("rooms/eros/messages/0", 0, @{}, NO); + FSTDocument *doc2 = FSTTestDoc("rooms/eros/messages/1", 0, @{}, NO); FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:[FSTDocumentKeySet keySet]]; // Start with a full view. @@ -494,7 +494,7 @@ NS_ASSUME_NONNULL_BEGIN [view applyChangesToDocuments:changes]; // Add a doc that is past the limit. - FSTDocument *doc3 = FSTTestDoc(@"rooms/eros/messages/2", 1, @{}, NO); + FSTDocument *doc3 = FSTTestDoc("rooms/eros/messages/2", 1, @{}, NO); changes = [view computeChangesWithDocuments:FSTTestDocUpdates(@[ doc3 ])]; [self assertDocSet:changes.documentSet containsDocs:@[ doc1, doc2 ]]; XCTAssertFalse(changes.needsRefill); @@ -504,8 +504,8 @@ NS_ASSUME_NONNULL_BEGIN - (void)testDoesntNeedRefillForDeletionsWhenNotNearTheLimit { FSTQuery *query = [[self queryForMessages] queryBySettingLimit:20]; - FSTDocument *doc1 = FSTTestDoc(@"rooms/eros/messages/0", 0, @{}, NO); - FSTDocument *doc2 = FSTTestDoc(@"rooms/eros/messages/1", 0, @{}, NO); + FSTDocument *doc1 = FSTTestDoc("rooms/eros/messages/0", 0, @{}, NO); + FSTDocument *doc2 = FSTTestDoc("rooms/eros/messages/1", 0, @{}, NO); FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:[FSTDocumentKeySet keySet]]; FSTViewDocumentChanges *changes = @@ -517,7 +517,7 @@ NS_ASSUME_NONNULL_BEGIN // Remove one of the docs. changes = [view computeChangesWithDocuments:FSTTestDocUpdates(@[ FSTTestDeletedDoc( - @"rooms/eros/messages/1", 0) ])]; + "rooms/eros/messages/1", 0) ])]; [self assertDocSet:changes.documentSet containsDocs:@[ doc1 ]]; XCTAssertFalse(changes.needsRefill); XCTAssertEqual(1, [changes.changeSet changes].count); @@ -526,8 +526,8 @@ NS_ASSUME_NONNULL_BEGIN - (void)testHandlesApplyingIrrelevantDocs { FSTQuery *query = [[self queryForMessages] queryBySettingLimit:2]; - FSTDocument *doc1 = FSTTestDoc(@"rooms/eros/messages/0", 0, @{}, NO); - FSTDocument *doc2 = FSTTestDoc(@"rooms/eros/messages/1", 0, @{}, NO); + FSTDocument *doc1 = FSTTestDoc("rooms/eros/messages/0", 0, @{}, NO); + FSTDocument *doc2 = FSTTestDoc("rooms/eros/messages/1", 0, @{}, NO); FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:[FSTDocumentKeySet keySet]]; // Start with a full view. @@ -540,7 +540,7 @@ NS_ASSUME_NONNULL_BEGIN // Remove a doc that isn't even in the results. changes = [view computeChangesWithDocuments:FSTTestDocUpdates(@[ FSTTestDeletedDoc( - @"rooms/eros/messages/2", 0) ])]; + "rooms/eros/messages/2", 0) ])]; [self assertDocSet:changes.documentSet containsDocs:@[ doc1, doc2 ]]; XCTAssertFalse(changes.needsRefill); XCTAssertEqual(0, [changes.changeSet changes].count); @@ -549,8 +549,8 @@ NS_ASSUME_NONNULL_BEGIN - (void)testComputesMutatedKeys { FSTQuery *query = [self queryForMessages]; - FSTDocument *doc1 = FSTTestDoc(@"rooms/eros/messages/0", 0, @{}, NO); - FSTDocument *doc2 = FSTTestDoc(@"rooms/eros/messages/1", 0, @{}, NO); + FSTDocument *doc1 = FSTTestDoc("rooms/eros/messages/0", 0, @{}, NO); + FSTDocument *doc2 = FSTTestDoc("rooms/eros/messages/1", 0, @{}, NO); FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:[FSTDocumentKeySet keySet]]; // Start with a full view. @@ -559,15 +559,15 @@ NS_ASSUME_NONNULL_BEGIN [view applyChangesToDocuments:changes]; XCTAssertEqualObjects(changes.mutatedKeys, FSTTestDocKeySet(@[])); - FSTDocument *doc3 = FSTTestDoc(@"rooms/eros/messages/2", 0, @{}, YES); + FSTDocument *doc3 = FSTTestDoc("rooms/eros/messages/2", 0, @{}, YES); changes = [view computeChangesWithDocuments:FSTTestDocUpdates(@[ doc3 ])]; XCTAssertEqualObjects(changes.mutatedKeys, FSTTestDocKeySet(@[ doc3.key ])); } - (void)testRemovesKeysFromMutatedKeysWhenNewDocHasNoLocalChanges { FSTQuery *query = [self queryForMessages]; - FSTDocument *doc1 = FSTTestDoc(@"rooms/eros/messages/0", 0, @{}, NO); - FSTDocument *doc2 = FSTTestDoc(@"rooms/eros/messages/1", 0, @{}, YES); + FSTDocument *doc1 = FSTTestDoc("rooms/eros/messages/0", 0, @{}, NO); + FSTDocument *doc2 = FSTTestDoc("rooms/eros/messages/1", 0, @{}, YES); FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:[FSTDocumentKeySet keySet]]; // Start with a full view. @@ -576,7 +576,7 @@ NS_ASSUME_NONNULL_BEGIN [view applyChangesToDocuments:changes]; XCTAssertEqualObjects(changes.mutatedKeys, FSTTestDocKeySet(@[ doc2.key ])); - FSTDocument *doc2Prime = FSTTestDoc(@"rooms/eros/messages/1", 0, @{}, NO); + FSTDocument *doc2Prime = FSTTestDoc("rooms/eros/messages/1", 0, @{}, NO); changes = [view computeChangesWithDocuments:FSTTestDocUpdates(@[ doc2Prime ])]; [view applyChangesToDocuments:changes]; XCTAssertEqualObjects(changes.mutatedKeys, FSTTestDocKeySet(@[])); @@ -584,8 +584,8 @@ NS_ASSUME_NONNULL_BEGIN - (void)testRemembersLocalMutationsFromPreviousSnapshot { FSTQuery *query = [self queryForMessages]; - FSTDocument *doc1 = FSTTestDoc(@"rooms/eros/messages/0", 0, @{}, NO); - FSTDocument *doc2 = FSTTestDoc(@"rooms/eros/messages/1", 0, @{}, YES); + FSTDocument *doc1 = FSTTestDoc("rooms/eros/messages/0", 0, @{}, NO); + FSTDocument *doc2 = FSTTestDoc("rooms/eros/messages/1", 0, @{}, YES); FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:[FSTDocumentKeySet keySet]]; // Start with a full view. @@ -594,7 +594,7 @@ NS_ASSUME_NONNULL_BEGIN [view applyChangesToDocuments:changes]; XCTAssertEqualObjects(changes.mutatedKeys, FSTTestDocKeySet(@[ doc2.key ])); - FSTDocument *doc3 = FSTTestDoc(@"rooms/eros/messages/2", 0, @{}, NO); + FSTDocument *doc3 = FSTTestDoc("rooms/eros/messages/2", 0, @{}, NO); changes = [view computeChangesWithDocuments:FSTTestDocUpdates(@[ doc3 ])]; [view applyChangesToDocuments:changes]; XCTAssertEqualObjects(changes.mutatedKeys, FSTTestDocKeySet(@[ doc2.key ])); @@ -602,8 +602,8 @@ NS_ASSUME_NONNULL_BEGIN - (void)testRemembersLocalMutationsFromPreviousCallToComputeChangesWithDocuments { FSTQuery *query = [self queryForMessages]; - FSTDocument *doc1 = FSTTestDoc(@"rooms/eros/messages/0", 0, @{}, NO); - FSTDocument *doc2 = FSTTestDoc(@"rooms/eros/messages/1", 0, @{}, YES); + FSTDocument *doc1 = FSTTestDoc("rooms/eros/messages/0", 0, @{}, NO); + FSTDocument *doc2 = FSTTestDoc("rooms/eros/messages/1", 0, @{}, YES); FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:[FSTDocumentKeySet keySet]]; // Start with a full view. @@ -611,7 +611,7 @@ NS_ASSUME_NONNULL_BEGIN [view computeChangesWithDocuments:FSTTestDocUpdates(@[ doc1, doc2 ])]; XCTAssertEqualObjects(changes.mutatedKeys, FSTTestDocKeySet(@[ doc2.key ])); - FSTDocument *doc3 = FSTTestDoc(@"rooms/eros/messages/2", 0, @{}, NO); + FSTDocument *doc3 = FSTTestDoc("rooms/eros/messages/2", 0, @{}, NO); changes = [view computeChangesWithDocuments:FSTTestDocUpdates(@[ doc3 ]) previousChanges:changes]; XCTAssertEqualObjects(changes.mutatedKeys, FSTTestDocKeySet(@[ doc2.key ])); } |