From 25f8691970a9f765a87ab3125776598c92e02744 Mon Sep 17 00:00:00 2001 From: Michael Lehenbauer Date: Tue, 10 Jul 2018 16:58:56 -0700 Subject: Expose array transforms and array contains queries. (#1514) Also remove test code that was combining multiple array contains queries since those were disallowed in https://github.com/firebase/firebase-ios-sdk/commit/0ec836f9ca71b27fa54a11ae9e07e60b8c5cc002 --- Firestore/Example/SwiftBuildTest/main.swift | 10 ++++------ .../Example/Tests/Integration/API/FIRQueryTests.mm | 21 +-------------------- .../Tests/Integration/API/FIRValidationTests.mm | 1 - 3 files changed, 5 insertions(+), 27 deletions(-) (limited to 'Firestore/Example') diff --git a/Firestore/Example/SwiftBuildTest/main.swift b/Firestore/Example/SwiftBuildTest/main.swift index c5034da..6773511 100644 --- a/Firestore/Example/SwiftBuildTest/main.swift +++ b/Firestore/Example/SwiftBuildTest/main.swift @@ -83,9 +83,8 @@ func makeRefs(database db: Firestore) -> (CollectionReference, DocumentReference func makeQuery(collection collectionRef: CollectionReference) -> Query { let query = collectionRef.whereField(FieldPath(["name"]), isEqualTo: "Fred") .whereField("age", isGreaterThanOrEqualTo: 24) - // TODO(array-features): Uncomment when API is publicly exposed. - // .whereField("tags", arrayContains:"active") - // .whereField(FieldPath(["tags"]), arrayContains:"active") + .whereField("tags", arrayContains: "active") + .whereField(FieldPath(["tags"]), arrayContains: "active") .whereField(FieldPath.documentID(), isEqualTo: "fred") .order(by: FieldPath(["age"])) .order(by: "name", descending: true) @@ -106,9 +105,8 @@ func writeDocument(at docRef: DocumentReference) { "bar.baz": 42, FieldPath(["foobar"]): 42, "server_timestamp": FieldValue.serverTimestamp(), - // TODO(array-features): Uncomment once we add these to the public API - // "array_union": FieldValue.arrayUnion(["a", "b"]), - // "array_remove": FieldValue.arrayRemove(["a", "b"]), + "array_union": FieldValue.arrayUnion(["a", "b"]), + "array_remove": FieldValue.arrayRemove(["a", "b"]), "field_delete": FieldValue.delete(), ] as [AnyHashable: Any] diff --git a/Firestore/Example/Tests/Integration/API/FIRQueryTests.mm b/Firestore/Example/Tests/Integration/API/FIRQueryTests.mm index bdd3df1..e634d7f 100644 --- a/Firestore/Example/Tests/Integration/API/FIRQueryTests.mm +++ b/Firestore/Example/Tests/Integration/API/FIRQueryTests.mm @@ -20,7 +20,6 @@ #import "Firestore/Example/Tests/Util/FSTEventAccumulator.h" #import "Firestore/Example/Tests/Util/FSTIntegrationTestCase.h" -#import "Firestore/Source/API/FIRQuery+Internal.h" @interface FIRQueryTests : FSTIntegrationTestCase @end @@ -293,8 +292,7 @@ ])); } -// TODO(array-features): Enable once backend support lands. -- (void)xtestArrayContainsQueries { +- (void)testArrayContainsQueries { NSDictionary *testDocs = @{ @"a" : @{@"array" : @[ @42 ]}, @"b" : @{@"array" : @[ @"a", @42, @"c" ]}, @@ -314,23 +312,6 @@ @"array2" : @[ @"bingo" ] } ])); - // Search for "array" to contain both @42 and "a". - snapshot = [self readDocumentSetForRef:[[collection queryWhereField:@"array" arrayContains:@42] - queryWhereField:@"array" - arrayContains:@"a"]]; - XCTAssertEqualObjects(FIRQuerySnapshotGetData(snapshot), (@[ - @{ @"array" : @[ @"a", @42, @"c" ] }, - ])); - - // Search two different array fields ("array" contains 42 and "array2" contains "bingo"). - snapshot = [self readDocumentSetForRef:[[collection queryWhereField:@"array" arrayContains:@42] - queryWhereField:@"array2" - arrayContains:@"bingo"]]; - XCTAssertEqualObjects(FIRQuerySnapshotGetData(snapshot), (@[ - @{ @"array" : @[ @42 ], - @"array2" : @[ @"bingo" ] } - ])); - // NOTE: The backend doesn't currently support null, NaN, objects, or arrays, so there isn't much // of anything else interesting to test. } diff --git a/Firestore/Example/Tests/Integration/API/FIRValidationTests.mm b/Firestore/Example/Tests/Integration/API/FIRValidationTests.mm index 599f1b2..fd37e5b 100644 --- a/Firestore/Example/Tests/Integration/API/FIRValidationTests.mm +++ b/Firestore/Example/Tests/Integration/API/FIRValidationTests.mm @@ -19,7 +19,6 @@ #import #import "Firestore/Source/API/FIRFieldValue+Internal.h" -#import "Firestore/Source/API/FIRQuery+Internal.h" #import "Firestore/Example/Tests/Util/FSTHelpers.h" #import "Firestore/Example/Tests/Util/FSTIntegrationTestCase.h" -- cgit v1.2.3