diff options
author | 2017-12-07 15:36:15 -0500 | |
---|---|---|
committer | 2017-12-07 15:36:15 -0500 | |
commit | 5da88e4b9b5ce9d1aee8611d03946e19bdfa5b65 (patch) | |
tree | 605cd2710e22d4ae8ab3c2bdfef33c996fd2244f /Firestore/Example/Tests/Integration/API | |
parent | a904be723a997ed434a36ce9562794a75673927e (diff) |
Implement NSPredicate-based query (#531)
* implement queryFilteredUsingPredicate in FIRQuery;
* add unit test and integration test for queryFilteredUsingPredicate;
* project change of adding the FIRQueryTests.m file;
* refactoring queryFilteredUsingPredicate to split logic into two helpers;
Diffstat (limited to 'Firestore/Example/Tests/Integration/API')
-rw-r--r-- | Firestore/Example/Tests/Integration/API/FIRQueryTests.m | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Firestore/Example/Tests/Integration/API/FIRQueryTests.m b/Firestore/Example/Tests/Integration/API/FIRQueryTests.m index 180b423..ccc635e 100644 --- a/Firestore/Example/Tests/Integration/API/FIRQueryTests.m +++ b/Firestore/Example/Tests/Integration/API/FIRQueryTests.m @@ -111,6 +111,23 @@ XCTAssertEqualObjects(FIRQuerySnapshotGetIDs(snapshot), (@[ @"b", @"a" ])); } +- (void)testQueryWithPredicate { + FIRCollectionReference *collRef = [self collectionRefWithDocuments:@{ + @"a" : @{@"a" : @1}, + @"b" : @{@"a" : @2}, + @"c" : @{@"a" : @3} + }]; + + NSPredicate *predicate = [NSPredicate predicateWithFormat:@"a < 3"]; + FIRQuery *query = [collRef queryFilteredUsingPredicate:predicate]; + query = [query queryOrderedByFieldPath:[[FIRFieldPath alloc] initWithFields:@[ @"a" ]] + descending:YES]; + + FIRQuerySnapshot *snapshot = [self readDocumentSetForRef:query]; + + XCTAssertEqualObjects(FIRQuerySnapshotGetIDs(snapshot), (@[ @"b", @"a" ])); +} + - (void)testFilterOnInfinity { FIRCollectionReference *collRef = [self collectionRefWithDocuments:@{ @"a" : @{@"inf" : @(INFINITY)}, |