aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Example
diff options
context:
space:
mode:
authorGravatar Michael Lehenbauer <mikelehen@gmail.com>2018-07-10 16:58:56 -0700
committerGravatar GitHub <noreply@github.com>2018-07-10 16:58:56 -0700
commit25f8691970a9f765a87ab3125776598c92e02744 (patch)
treeefdef14fd22c313411b9125d4804fd59aa114d5e /Firestore/Example
parent6466c35737eff21e9b48c3ce2353d42628f4bb77 (diff)
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
Diffstat (limited to 'Firestore/Example')
-rw-r--r--Firestore/Example/SwiftBuildTest/main.swift10
-rw-r--r--Firestore/Example/Tests/Integration/API/FIRQueryTests.mm21
-rw-r--r--Firestore/Example/Tests/Integration/API/FIRValidationTests.mm1
3 files changed, 5 insertions, 27 deletions
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 <XCTest/XCTest.h>
#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"