Skip to content

Commit 90dedd3

Browse files
authored
Merge pull request #639 from firebase/firestore-api-changes
Merge firestore-api-changes to master for next release.
2 parents 4dd07c6 + dc0b29e commit 90dedd3

File tree

98 files changed

+2557
-642
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+2557
-642
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,6 @@ Podfile.lock
5959
*.xcworkspace
6060

6161
# CMake
62+
.downloads
6263
Debug
6364
Release

Firestore/CHANGELOG.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
# Unreleased
1+
# Unreleased (firestore-api-changes)
2+
- [changed] Removed the includeMetadataChanges property in FIRDocumentListenOptions
3+
to avoid confusion with the factory method of the same name.
4+
- [changed] Added a commit method that takes no completion handler to FIRWriteBatch.
5+
- [feature] Queries can now be created from an NSPredicate.
6+
- [added] Added SnapshotOptions API to control how DocumentSnapshots return unresolved
7+
server timestamps.
8+
- [changed] For non-existing documents, DocumentSnapshot.data() now returns `nil`
9+
instead of throwing an exception. A non-nullable QueryDocumentSnapshot is
10+
introduced for Queries to reduce the number of nil-checks in your code.
11+
- [changed] Snapshot listeners (with the `includeMetadataChanges` option
12+
enabled) now receive an event with `snapshot.metadata.isFromCache` set to
13+
`true` if the SDK loses its connection to the backend. A new event with
14+
`snapshot.metadata.isFromCache` set to false will be raised once the
15+
connection is restored and the query is in sync with the backend again.
216

317
# v0.9.4
418
- [changed] Firestore no longer has a direct dependency on FirebaseAuth.

Firestore/Example/Firestore.xcodeproj/project.pbxproj

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@
6363
6ED54761B845349D43DB6B78 /* Pods_Firestore_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 75A6FE51C1A02DF38F62FAAD /* Pods_Firestore_Example.framework */; };
6464
71719F9F1E33DC2100824A3D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 71719F9D1E33DC2100824A3D /* LaunchScreen.storyboard */; };
6565
873B8AEB1B1F5CCA007FD442 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */; };
66+
AB382F7C1FE02A1F007CA955 /* FIRDocumentReferenceTests.m in Sources */ = {isa = PBXBuildFile; fileRef = AB382F7B1FE02A1F007CA955 /* FIRDocumentReferenceTests.m */; };
67+
AB382F7E1FE03059007CA955 /* FIRFieldPathTests.m in Sources */ = {isa = PBXBuildFile; fileRef = AB382F7D1FE03059007CA955 /* FIRFieldPathTests.m */; };
68+
AB9945261FE2D71100DFC1E6 /* FIRCollectionReferenceTests.m in Sources */ = {isa = PBXBuildFile; fileRef = AB9945251FE2D71100DFC1E6 /* FIRCollectionReferenceTests.m */; };
69+
AB9945281FE2DE0C00DFC1E6 /* FIRSnapshotMetadataTests.m in Sources */ = {isa = PBXBuildFile; fileRef = AB9945271FE2DE0C00DFC1E6 /* FIRSnapshotMetadataTests.m */; };
70+
AB99452A1FE2F9EB00DFC1E6 /* FIRDocumentSnapshotTests.m in Sources */ = {isa = PBXBuildFile; fileRef = AB9945291FE2F9EB00DFC1E6 /* FIRDocumentSnapshotTests.m */; };
71+
AB99452C1FE3018D00DFC1E6 /* FIRQuerySnapshotTests.m in Sources */ = {isa = PBXBuildFile; fileRef = AB99452B1FE3018D00DFC1E6 /* FIRQuerySnapshotTests.m */; };
72+
AB99452E1FE30AC800DFC1E6 /* FIRFieldValueTests.m in Sources */ = {isa = PBXBuildFile; fileRef = AB99452D1FE30AC800DFC1E6 /* FIRFieldValueTests.m */; };
73+
ABAEEF4F1FD5F8B100C966CB /* FIRQueryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = ABAEEF4E1FD5F8B100C966CB /* FIRQueryTests.m */; };
74+
ABF341051FE860CA00C48322 /* FSTAPIHelpers.m in Sources */ = {isa = PBXBuildFile; fileRef = ABF341021FE8593500C48322 /* FSTAPIHelpers.m */; };
6675
AFE6114F0D4DAECBA7B7C089 /* Pods_Firestore_IntegrationTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B2FA635DF5D116A67A7441CD /* Pods_Firestore_IntegrationTests.framework */; };
6776
C4E749275AD0FBDF9F4716A8 /* Pods_SwiftBuildTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 32AD40BF6B0E849B07FFD05E /* Pods_SwiftBuildTest.framework */; };
6877
D5B2532E4676014F57A7EAB9 /* FSTStreamTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D5B25C0D4AADFCA3ADB883E4 /* FSTStreamTests.m */; };
@@ -234,6 +243,16 @@
234243
8E002F4AD5D9B6197C940847 /* Firestore.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = Firestore.podspec; path = ../Firestore.podspec; sourceTree = "<group>"; };
235244
9D52E67EE96AA7E5D6F69748 /* Pods-Firestore_IntegrationTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Firestore_IntegrationTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Firestore_IntegrationTests/Pods-Firestore_IntegrationTests.debug.xcconfig"; sourceTree = "<group>"; };
236245
9EF477AD4B2B643FD320867A /* Pods-Firestore_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Firestore_Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Firestore_Example/Pods-Firestore_Example.debug.xcconfig"; sourceTree = "<group>"; };
246+
AB382F7B1FE02A1F007CA955 /* FIRDocumentReferenceTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FIRDocumentReferenceTests.m; sourceTree = "<group>"; };
247+
AB382F7D1FE03059007CA955 /* FIRFieldPathTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FIRFieldPathTests.m; sourceTree = "<group>"; };
248+
AB9945251FE2D71100DFC1E6 /* FIRCollectionReferenceTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FIRCollectionReferenceTests.m; sourceTree = "<group>"; };
249+
AB9945271FE2DE0C00DFC1E6 /* FIRSnapshotMetadataTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FIRSnapshotMetadataTests.m; sourceTree = "<group>"; };
250+
AB9945291FE2F9EB00DFC1E6 /* FIRDocumentSnapshotTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FIRDocumentSnapshotTests.m; sourceTree = "<group>"; };
251+
AB99452B1FE3018D00DFC1E6 /* FIRQuerySnapshotTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FIRQuerySnapshotTests.m; sourceTree = "<group>"; };
252+
AB99452D1FE30AC800DFC1E6 /* FIRFieldValueTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FIRFieldValueTests.m; sourceTree = "<group>"; };
253+
ABAEEF4E1FD5F8B100C966CB /* FIRQueryTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FIRQueryTests.m; sourceTree = "<group>"; };
254+
ABF341011FE858B500C48322 /* FSTAPIHelpers.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FSTAPIHelpers.h; sourceTree = "<group>"; };
255+
ABF341021FE8593500C48322 /* FSTAPIHelpers.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FSTAPIHelpers.m; sourceTree = "<group>"; };
237256
B2FA635DF5D116A67A7441CD /* Pods_Firestore_IntegrationTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Firestore_IntegrationTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
238257
CE00BABB5A3AAB44A4C209E2 /* Pods-Firestore_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Firestore_Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Firestore_Tests/Pods-Firestore_Tests.debug.xcconfig"; sourceTree = "<group>"; };
239258
D3CC3DC5338DCAF43A211155 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
@@ -589,7 +608,17 @@
589608
DE51B1831F0D48AC0013853F /* API */ = {
590609
isa = PBXGroup;
591610
children = (
611+
AB99452D1FE30AC800DFC1E6 /* FIRFieldValueTests.m */,
612+
AB99452B1FE3018D00DFC1E6 /* FIRQuerySnapshotTests.m */,
613+
AB9945291FE2F9EB00DFC1E6 /* FIRDocumentSnapshotTests.m */,
614+
AB9945271FE2DE0C00DFC1E6 /* FIRSnapshotMetadataTests.m */,
615+
AB9945251FE2D71100DFC1E6 /* FIRCollectionReferenceTests.m */,
616+
AB382F7D1FE03059007CA955 /* FIRFieldPathTests.m */,
617+
AB382F7B1FE02A1F007CA955 /* FIRDocumentReferenceTests.m */,
592618
DE51B1841F0D48AC0013853F /* FIRGeoPointTests.m */,
619+
ABAEEF4E1FD5F8B100C966CB /* FIRQueryTests.m */,
620+
ABF341011FE858B500C48322 /* FSTAPIHelpers.h */,
621+
ABF341021FE8593500C48322 /* FSTAPIHelpers.m */,
593622
);
594623
path = API;
595624
sourceTree = "<group>";
@@ -923,8 +952,7 @@
923952
inputPaths = (
924953
"${SRCROOT}/Pods/Target Support Files/Pods-SwiftBuildTest/Pods-SwiftBuildTest-frameworks.sh",
925954
"${BUILT_PRODUCTS_DIR}/BoringSSL/openssl.framework",
926-
"${BUILT_PRODUCTS_DIR}/GTMSessionFetcher/GTMSessionFetcher.framework",
927-
"${BUILT_PRODUCTS_DIR}/GoogleToolboxForMac-f0850809/GoogleToolboxForMac.framework",
955+
"${BUILT_PRODUCTS_DIR}/GoogleToolboxForMac-Defines-NSData+zlib/GoogleToolboxForMac.framework",
928956
"${BUILT_PRODUCTS_DIR}/Protobuf/Protobuf.framework",
929957
"${BUILT_PRODUCTS_DIR}/gRPC/GRPCClient.framework",
930958
"${BUILT_PRODUCTS_DIR}/gRPC-Core/grpc.framework",
@@ -936,7 +964,6 @@
936964
name = "[CP] Embed Pods Frameworks";
937965
outputPaths = (
938966
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/openssl.framework",
939-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GTMSessionFetcher.framework",
940967
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleToolboxForMac.framework",
941968
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Protobuf.framework",
942969
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GRPCClient.framework",
@@ -1167,7 +1194,9 @@
11671194
files = (
11681195
DE2EF0881F3D0B6E003D0CDC /* FSTTreeSortedDictionaryTests.m in Sources */,
11691196
DE51B1FD1F0D492C0013853F /* FSTSpecTests.m in Sources */,
1197+
ABAEEF4F1FD5F8B100C966CB /* FIRQueryTests.m in Sources */,
11701198
DE51B2001F0D493A0013853F /* FSTComparisonTests.m in Sources */,
1199+
ABF341051FE860CA00C48322 /* FSTAPIHelpers.m in Sources */,
11711200
DE51B1CC1F0D48C00013853F /* FIRGeoPointTests.m in Sources */,
11721201
DE51B1E11F0D490D0013853F /* FSTMemoryRemoteDocumentCacheTests.m in Sources */,
11731202
DE51B1FF1F0D493A0013853F /* FSTAssertTests.m in Sources */,
@@ -1179,6 +1208,7 @@
11791208
DE51B2011F0D493E0013853F /* FSTHelpers.m in Sources */,
11801209
DE51B1F61F0D491B0013853F /* FSTSerializerBetaTests.m in Sources */,
11811210
DE51B1F01F0D49140013853F /* FSTFieldValueTests.m in Sources */,
1211+
AB9945281FE2DE0C00DFC1E6 /* FIRSnapshotMetadataTests.m in Sources */,
11821212
5491BC721FB44593008B3588 /* FSTIntegrationTestCase.mm in Sources */,
11831213
DE2EF0861F3D0B6E003D0CDC /* FSTImmutableSortedDictionary+Testing.m in Sources */,
11841214
DE51B1DE1F0D490D0013853F /* FSTMemoryLocalStoreTests.m in Sources */,
@@ -1192,6 +1222,7 @@
11921222
5436F32420008FAD006E51E3 /* string_printf_test.cc in Sources */,
11931223
DE51B1EF1F0D49140013853F /* FSTDocumentTests.m in Sources */,
11941224
DE51B1DC1F0D490D0013853F /* FSTLocalSerializerTests.m in Sources */,
1225+
AB99452A1FE2F9EB00DFC1E6 /* FIRDocumentSnapshotTests.m in Sources */,
11951226
DE51B1E71F0D490D0013853F /* FSTRemoteDocumentChangeBufferTests.m in Sources */,
11961227
DE51B1E51F0D490D0013853F /* FSTReferenceSetTests.m in Sources */,
11971228
DE51B1EA1F0D490D0013853F /* FSTLevelDBRemoteDocumentCacheTests.mm in Sources */,
@@ -1203,6 +1234,7 @@
12031234
DE51B1DB1F0D490D0013853F /* FSTLevelDBQueryCacheTests.m in Sources */,
12041235
54764FAB1FAA0C320085E60A /* string_util_test.cc in Sources */,
12051236
54E9282C1F339CAD00C1953E /* XCTestCase+Await.m in Sources */,
1237+
AB99452E1FE30AC800DFC1E6 /* FIRFieldValueTests.m in Sources */,
12061238
DE51B1DF1F0D490D0013853F /* FSTMemoryMutationQueueTests.m in Sources */,
12071239
DE51B1F31F0D491B0013853F /* FSTDatastoreTests.m in Sources */,
12081240
DE51B1D01F0D48CD0013853F /* FSTQueryTests.m in Sources */,
@@ -1215,7 +1247,9 @@
12151247
DE51B1D91F0D490D0013853F /* FSTEagerGarbageCollectorTests.m in Sources */,
12161248
DE51B1E21F0D490D0013853F /* FSTMutationQueueTests.m in Sources */,
12171249
DE51B1E81F0D490D0013853F /* FSTLevelDBKeyTests.mm in Sources */,
1250+
AB9945261FE2D71100DFC1E6 /* FIRCollectionReferenceTests.m in Sources */,
12181251
DE51B1E31F0D490D0013853F /* FSTPersistenceTestHelpers.m in Sources */,
1252+
AB382F7C1FE02A1F007CA955 /* FIRDocumentReferenceTests.m in Sources */,
12191253
DE51B1CF1F0D48CD0013853F /* FSTQueryListenerTests.m in Sources */,
12201254
DE51B1DA1F0D490D0013853F /* FSTLevelDBLocalStoreTests.m in Sources */,
12211255
DE51B1FA1F0D492C0013853F /* FSTLevelDBSpecTests.m in Sources */,
@@ -1224,7 +1258,9 @@
12241258
DE51B1CE1F0D48CD0013853F /* FSTEventManagerTests.m in Sources */,
12251259
DE51B1E41F0D490D0013853F /* FSTQueryCacheTests.m in Sources */,
12261260
DE51B1CD1F0D48CD0013853F /* FSTDatabaseInfoTests.m in Sources */,
1261+
AB382F7E1FE03059007CA955 /* FIRFieldPathTests.m in Sources */,
12271262
DE51B1F21F0D49140013853F /* FSTPathTests.m in Sources */,
1263+
AB99452C1FE3018D00DFC1E6 /* FIRQuerySnapshotTests.m in Sources */,
12281264
54740A571FC914BA00713A1A /* secure_random_test.cc in Sources */,
12291265
DE51B1DD1F0D490D0013853F /* FSTLocalStoreTests.m in Sources */,
12301266
D5B25474286C9800CE42B8C2 /* FSTTestDispatchQueue.m in Sources */,

Firestore/Example/SwiftBuildTest/main.swift

Lines changed: 80 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ func main() {
2727

2828
writeDocument(at: documentRef);
2929

30+
writeDocuments(at: documentRef, database: db);
31+
3032
addDocument(to: collectionRef);
3133

3234
readDocument(at: documentRef);
@@ -37,6 +39,8 @@ func main() {
3739

3840
listenToDocuments(matching: query);
3941

42+
enableDisableNetwork(database: db);
43+
4044
types();
4145
}
4246

@@ -129,6 +133,47 @@ func writeDocument(at docRef: DocumentReference) {
129133
}
130134
}
131135

136+
func enableDisableNetwork(database db: Firestore) {
137+
// closure syntax
138+
db.disableNetwork(completion: { (error) in
139+
if let e = error {
140+
print("Uh oh! \(e)")
141+
return
142+
}
143+
})
144+
// trailing block syntax
145+
db.enableNetwork { (error) in
146+
if let e = error {
147+
print("Uh oh! \(e)")
148+
return
149+
}
150+
}
151+
}
152+
153+
func writeDocuments(at docRef: DocumentReference, database db: Firestore) {
154+
var batch: WriteBatch;
155+
156+
batch = db.batch();
157+
batch.setData(["a" : "b"], forDocument:docRef);
158+
batch.setData(["c" : "d"], forDocument:docRef);
159+
// commit without completion callback.
160+
batch.commit();
161+
print("Batch write without completion complete!");
162+
163+
batch = db.batch();
164+
batch.setData(["a" : "b"], forDocument:docRef);
165+
batch.setData(["c" : "d"], forDocument:docRef);
166+
// commit with completion callback via trailing closure syntax.
167+
batch.commit() { error in
168+
if let error = error {
169+
print("Uh oh! \(error)");
170+
return;
171+
}
172+
print("Batch write callback complete!");
173+
}
174+
print("Batch write with completion complete!");
175+
}
176+
132177
func addDocument(to collectionRef: CollectionReference) {
133178

134179
collectionRef.addDocument(data: ["foo": 42]);
@@ -141,11 +186,20 @@ func readDocument(at docRef: DocumentReference) {
141186
// Trailing closure syntax.
142187
docRef.getDocument() { document, error in
143188
if let document = document {
144-
// NOTE that document is nullable.
145-
let data = document.data();
189+
// Note that both document and document.data() is nullable.
190+
if let data = document.data() {
146191
print("Read document: \(data)")
147-
148-
// Fields are read via subscript notation.
192+
}
193+
if let data = document.data(with:SnapshotOptions.serverTimestampBehavior(.estimate)) {
194+
print("Read document: \(data)")
195+
}
196+
if let foo = document.get("foo") {
197+
print("Field: \(foo)")
198+
}
199+
if let foo = document.get("foo", options: SnapshotOptions.serverTimestampBehavior(.previous)) {
200+
print("Field: \(foo)")
201+
}
202+
// Fields can also be read via subscript notation.
149203
if let foo = document["foo"] {
150204
print("Field: \(foo)")
151205
}
@@ -181,24 +235,27 @@ func readDocuments(matching query: Query) {
181235

182236
func listenToDocument(at docRef: DocumentReference) {
183237

184-
let listener = docRef.addSnapshotListener() { document, error in
185-
if let error = error {
186-
print("Uh oh! Listen canceled: \(error)")
187-
return
188-
}
238+
let listener = docRef.addSnapshotListener() { document, error in
239+
if let error = error {
240+
print("Uh oh! Listen canceled: \(error)")
241+
return
242+
}
189243

190-
if let document = document {
191-
print("Current document: \(document.data())");
192-
if (document.metadata.isFromCache) {
193-
print("From Cache")
194-
} else {
195-
print("From Server")
196-
}
197-
}
244+
if let document = document {
245+
// Note that document.data() is nullable.
246+
if let data : [String:Any] = document.data() {
247+
print("Current document: \(data)");
248+
}
249+
if document.metadata.isFromCache {
250+
print("From Cache")
251+
} else {
252+
print("From Server")
253+
}
198254
}
255+
}
199256

200-
// Unsubscribe.
201-
listener.remove();
257+
// Unsubscribe.
258+
listener.remove();
202259
}
203260

204261
func listenToDocuments(matching query: Query) {
@@ -215,7 +272,9 @@ func listenToDocuments(matching query: Query) {
215272
// TODO(mikelehen): Figure out how to make "for..in" syntax work
216273
// directly on documentSet.
217274
for document in snap.documents {
218-
print("Doc: ", document.data())
275+
// Note that document.data() is not nullable.
276+
let data : [String:Any] = document.data()
277+
print("Doc: ", data)
219278
}
220279
}
221280
}
@@ -258,7 +317,7 @@ func transactions() {
258317
let balanceA = try transaction.getDocument(accA)["balance"] as! Double
259318
let balanceB = try transaction.getDocument(accB)["balance"] as! Double
260319

261-
if (balanceA < amount) {
320+
if balanceA < amount {
262321
errorPointer?.pointee = NSError(domain: "Foo", code: 123, userInfo: nil)
263322
return nil
264323
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2017 Google
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#import <XCTest/XCTest.h>
18+
19+
#import "FirebaseFirestore/FIRCollectionReference.h"
20+
21+
#import "Firestore/Example/Tests/API/FSTAPIHelpers.h"
22+
23+
NS_ASSUME_NONNULL_BEGIN
24+
25+
@interface FIRCollectionReferenceTests : XCTestCase
26+
@end
27+
28+
@implementation FIRCollectionReferenceTests
29+
30+
- (void)testEquals {
31+
FIRCollectionReference *referenceFoo = FSTTestCollectionRef(@"foo");
32+
FIRCollectionReference *referenceFooDup = FSTTestCollectionRef(@"foo");
33+
FIRCollectionReference *referenceBar = FSTTestCollectionRef(@"bar");
34+
XCTAssertEqualObjects(referenceFoo, referenceFooDup);
35+
XCTAssertNotEqualObjects(referenceFoo, referenceBar);
36+
37+
XCTAssertEqual([referenceFoo hash], [referenceFooDup hash]);
38+
XCTAssertNotEqual([referenceFoo hash], [referenceBar hash]);
39+
}
40+
41+
@end
42+
43+
NS_ASSUME_NONNULL_END
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2017 Google
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#import <XCTest/XCTest.h>
18+
19+
#import "FirebaseFirestore/FIRDocumentReference.h"
20+
21+
#import "Firestore/Example/Tests/API/FSTAPIHelpers.h"
22+
23+
NS_ASSUME_NONNULL_BEGIN
24+
25+
@interface FIRDocumentReferenceTests : XCTestCase
26+
@end
27+
28+
@implementation FIRDocumentReferenceTests
29+
30+
- (void)testEquals {
31+
FIRDocumentReference *referenceFoo = FSTTestDocRef(@"rooms/foo");
32+
FIRDocumentReference *referenceFooDup = FSTTestDocRef(@"rooms/foo");
33+
FIRDocumentReference *referenceBar = FSTTestDocRef(@"rooms/bar");
34+
XCTAssertEqualObjects(referenceFoo, referenceFooDup);
35+
XCTAssertNotEqualObjects(referenceFoo, referenceBar);
36+
37+
XCTAssertEqual([referenceFoo hash], [referenceFooDup hash]);
38+
XCTAssertNotEqual([referenceFoo hash], [referenceBar hash]);
39+
}
40+
41+
@end
42+
43+
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)