aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Example/Tests
diff options
context:
space:
mode:
authorGravatar zxu <zxu@google.com>2018-03-16 15:42:05 -0400
committerGravatar GitHub <noreply@github.com>2018-03-16 15:42:05 -0400
commit4e7296b080b9c8cea13e5e5eeee65f4312fb5e8a (patch)
tree87f175b1e1ac74632fee2ff7c52ccb9b5bc78014 /Firestore/Example/Tests
parent1395c8202b236188b9e4e1bfc2a3e00244179593 (diff)
port `DocumentKey` to non-container types of `Model/*` (#930)
* naively remove FSTPath import and source/test files. * port FieldPath, part I * port FieldPath, part II * port ResourcePath, part I * port ResourcePath, part II * the grand commit to fix build errors * use testutil:: helper instead of those from FSTHelpers * fix test and lint * use c_str in errmsg directly * fix * fix * make code clean * fix integration test I missed * fix to avoid naming collision in preprocessor * address changes * address changes * address changes * fix: fieldMask are actually shared with different context. * address changes * add converter function between two DocumentKey implementations * add unit test * address changes * fix lint * using DocumentKey in model except for the container types `FSTDocumentDictionary`, `FSTDocumentKeySet`, and `FSTDocumentVersionDictionary` * change other place w.r.t. the use of `DocumentKey` in model * update parameter of test helpers from NSString to string_view * revert a temporary change used in debug * address changes
Diffstat (limited to 'Firestore/Example/Tests')
-rw-r--r--Firestore/Example/Tests/API/FIRDocumentSnapshotTests.mm16
-rw-r--r--Firestore/Example/Tests/API/FIRQuerySnapshotTests.mm12
-rw-r--r--Firestore/Example/Tests/API/FSTAPIHelpers.h6
-rw-r--r--Firestore/Example/Tests/API/FSTAPIHelpers.mm33
-rw-r--r--Firestore/Example/Tests/Core/FSTQueryListenerTests.mm48
-rw-r--r--Firestore/Example/Tests/Core/FSTQueryTests.mm148
-rw-r--r--Firestore/Example/Tests/Core/FSTViewSnapshotTest.mm22
-rw-r--r--Firestore/Example/Tests/Core/FSTViewTests.mm150
-rw-r--r--Firestore/Example/Tests/Local/FSTLocalSerializerTests.mm4
-rw-r--r--Firestore/Example/Tests/Local/FSTLocalStoreTests.mm254
-rw-r--r--Firestore/Example/Tests/Local/FSTRemoteDocumentCacheTests.mm33
-rw-r--r--Firestore/Example/Tests/Local/FSTRemoteDocumentChangeBufferTests.mm6
-rw-r--r--Firestore/Example/Tests/Model/FSTDocumentSetTests.mm10
-rw-r--r--Firestore/Example/Tests/Model/FSTDocumentTests.mm31
-rw-r--r--Firestore/Example/Tests/Model/FSTMutationTests.mm49
-rw-r--r--Firestore/Example/Tests/Remote/FSTRemoteEventTests.mm66
-rw-r--r--Firestore/Example/Tests/Remote/FSTSerializerBetaTests.mm6
-rw-r--r--Firestore/Example/Tests/Remote/FSTWatchChangeTests.mm2
-rw-r--r--Firestore/Example/Tests/SpecTests/FSTSpecTests.mm4
-rw-r--r--Firestore/Example/Tests/Util/FSTHelpers.h4
-rw-r--r--Firestore/Example/Tests/Util/FSTHelpers.mm11
21 files changed, 466 insertions, 449 deletions
diff --git a/Firestore/Example/Tests/API/FIRDocumentSnapshotTests.mm b/Firestore/Example/Tests/API/FIRDocumentSnapshotTests.mm
index 677d385..136fed6 100644
--- a/Firestore/Example/Tests/API/FIRDocumentSnapshotTests.mm
+++ b/Firestore/Example/Tests/API/FIRDocumentSnapshotTests.mm
@@ -28,14 +28,14 @@ NS_ASSUME_NONNULL_BEGIN
@implementation FIRDocumentSnapshotTests
- (void)testEquals {
- FIRDocumentSnapshot *base = FSTTestDocSnapshot(@"rooms/foo", 1, @{ @"a" : @1 }, NO, NO);
- FIRDocumentSnapshot *baseDup = FSTTestDocSnapshot(@"rooms/foo", 1, @{ @"a" : @1 }, NO, NO);
- FIRDocumentSnapshot *nilData = FSTTestDocSnapshot(@"rooms/foo", 1, nil, NO, NO);
- FIRDocumentSnapshot *nilDataDup = FSTTestDocSnapshot(@"rooms/foo", 1, nil, NO, NO);
- FIRDocumentSnapshot *differentPath = FSTTestDocSnapshot(@"rooms/bar", 1, @{ @"a" : @1 }, NO, NO);
- FIRDocumentSnapshot *differentData = FSTTestDocSnapshot(@"rooms/bar", 1, @{ @"b" : @1 }, NO, NO);
- FIRDocumentSnapshot *hasMutations = FSTTestDocSnapshot(@"rooms/bar", 1, @{ @"a" : @1 }, YES, NO);
- FIRDocumentSnapshot *fromCache = FSTTestDocSnapshot(@"rooms/bar", 1, @{ @"a" : @1 }, NO, YES);
+ FIRDocumentSnapshot *base = FSTTestDocSnapshot("rooms/foo", 1, @{ @"a" : @1 }, NO, NO);
+ FIRDocumentSnapshot *baseDup = FSTTestDocSnapshot("rooms/foo", 1, @{ @"a" : @1 }, NO, NO);
+ FIRDocumentSnapshot *nilData = FSTTestDocSnapshot("rooms/foo", 1, nil, NO, NO);
+ FIRDocumentSnapshot *nilDataDup = FSTTestDocSnapshot("rooms/foo", 1, nil, NO, NO);
+ FIRDocumentSnapshot *differentPath = FSTTestDocSnapshot("rooms/bar", 1, @{ @"a" : @1 }, NO, NO);
+ FIRDocumentSnapshot *differentData = FSTTestDocSnapshot("rooms/bar", 1, @{ @"b" : @1 }, NO, NO);
+ FIRDocumentSnapshot *hasMutations = FSTTestDocSnapshot("rooms/bar", 1, @{ @"a" : @1 }, YES, NO);
+ FIRDocumentSnapshot *fromCache = FSTTestDocSnapshot("rooms/bar", 1, @{ @"a" : @1 }, NO, YES);
XCTAssertEqualObjects(base, baseDup);
XCTAssertEqualObjects(nilData, nilDataDup);
XCTAssertNotEqualObjects(base, nilData);
diff --git a/Firestore/Example/Tests/API/FIRQuerySnapshotTests.mm b/Firestore/Example/Tests/API/FIRQuerySnapshotTests.mm
index bb8110b..f8c7d60 100644
--- a/Firestore/Example/Tests/API/FIRQuerySnapshotTests.mm
+++ b/Firestore/Example/Tests/API/FIRQuerySnapshotTests.mm
@@ -28,15 +28,15 @@ NS_ASSUME_NONNULL_BEGIN
@implementation FIRQuerySnapshotTests
- (void)testEquals {
- FIRQuerySnapshot *foo = FSTTestQuerySnapshot(@"foo", @{}, @{ @"a" : @{@"a" : @1} }, YES, NO);
- FIRQuerySnapshot *fooDup = FSTTestQuerySnapshot(@"foo", @{}, @{ @"a" : @{@"a" : @1} }, YES, NO);
- FIRQuerySnapshot *differentPath = FSTTestQuerySnapshot(@"bar", @{},
+ FIRQuerySnapshot *foo = FSTTestQuerySnapshot("foo", @{}, @{ @"a" : @{@"a" : @1} }, YES, NO);
+ FIRQuerySnapshot *fooDup = FSTTestQuerySnapshot("foo", @{}, @{ @"a" : @{@"a" : @1} }, YES, NO);
+ FIRQuerySnapshot *differentPath = FSTTestQuerySnapshot("bar", @{},
@{ @"a" : @{@"a" : @1} }, YES, NO);
- FIRQuerySnapshot *differentDoc = FSTTestQuerySnapshot(@"foo",
+ FIRQuerySnapshot *differentDoc = FSTTestQuerySnapshot("foo",
@{ @"a" : @{@"b" : @1} }, @{}, YES, NO);
- FIRQuerySnapshot *noPendingWrites = FSTTestQuerySnapshot(@"foo", @{},
+ FIRQuerySnapshot *noPendingWrites = FSTTestQuerySnapshot("foo", @{},
@{ @"a" : @{@"a" : @1} }, NO, NO);
- FIRQuerySnapshot *fromCache = FSTTestQuerySnapshot(@"foo", @{},
+ FIRQuerySnapshot *fromCache = FSTTestQuerySnapshot("foo", @{},
@{ @"a" : @{@"a" : @1} }, YES, YES);
XCTAssertEqualObjects(foo, fooDup);
XCTAssertNotEqualObjects(foo, differentPath);
diff --git a/Firestore/Example/Tests/API/FSTAPIHelpers.h b/Firestore/Example/Tests/API/FSTAPIHelpers.h
index 4edd7d5..2325c22 100644
--- a/Firestore/Example/Tests/API/FSTAPIHelpers.h
+++ b/Firestore/Example/Tests/API/FSTAPIHelpers.h
@@ -18,6 +18,8 @@
#import "Firestore/Example/Tests/Util/FSTHelpers.h"
+#include "absl/strings/string_view.h"
+
@class FIRCollectionReference;
@class FIRDocumentReference;
@class FIRDocumentSnapshot;
@@ -34,7 +36,7 @@ extern "C" {
FIRFirestore *FSTTestFirestore();
/** A convenience method for creating a doc snapshot for tests. */
-FIRDocumentSnapshot *FSTTestDocSnapshot(NSString *path,
+FIRDocumentSnapshot *FSTTestDocSnapshot(const absl::string_view path,
FSTTestSnapshotVersion version,
NSDictionary<NSString *, id> *_Nullable data,
BOOL hasMutations,
@@ -61,7 +63,7 @@ FIRDocumentReference *FSTTestDocRef(const absl::string_view path);
* @returns A query snapshot that consists of both sets of documents.
*/
FIRQuerySnapshot *FSTTestQuerySnapshot(
- NSString *path,
+ const absl::string_view path,
NSDictionary<NSString *, NSDictionary<NSString *, id> *> *oldDocs,
NSDictionary<NSString *, NSDictionary<NSString *, id> *> *docsToAdd,
BOOL hasPendingWrites,
diff --git a/Firestore/Example/Tests/API/FSTAPIHelpers.mm b/Firestore/Example/Tests/API/FSTAPIHelpers.mm
index c180dc4..1ccf22e 100644
--- a/Firestore/Example/Tests/API/FSTAPIHelpers.mm
+++ b/Firestore/Example/Tests/API/FSTAPIHelpers.mm
@@ -58,14 +58,14 @@ FIRFirestore *FSTTestFirestore() {
return sharedInstance;
}
-FIRDocumentSnapshot *FSTTestDocSnapshot(NSString *path,
+FIRDocumentSnapshot *FSTTestDocSnapshot(const absl::string_view path,
FSTTestSnapshotVersion version,
NSDictionary<NSString *, id> *_Nullable data,
BOOL hasMutations,
BOOL fromCache) {
FSTDocument *doc = data ? FSTTestDoc(path, version, data, hasMutations) : nil;
return [FIRDocumentSnapshot snapshotWithFirestore:FSTTestFirestore()
- documentKey:FSTTestDocKey(path)
+ documentKey:testutil::Key(path)
document:doc
fromCache:fromCache];
}
@@ -82,7 +82,7 @@ FIRDocumentReference *FSTTestDocRef(const absl::string_view path) {
/** A convenience method for creating a query snapshots for tests. */
FIRQuerySnapshot *FSTTestQuerySnapshot(
- NSString *path,
+ const absl::string_view path,
NSDictionary<NSString *, NSDictionary<NSString *, id> *> *oldDocs,
NSDictionary<NSString *, NSDictionary<NSString *, id> *> *docsToAdd,
BOOL hasPendingWrites,
@@ -92,30 +92,31 @@ FIRQuerySnapshot *FSTTestQuerySnapshot(
FSTDocumentSet *oldDocuments = FSTTestDocSet(FSTDocumentComparatorByKey, @[]);
for (NSString *key in oldDocs) {
oldDocuments = [oldDocuments
- documentSetByAddingDocument:FSTTestDoc([NSString stringWithFormat:@"%@/%@", path, key], 1,
- oldDocs[key], hasPendingWrites)];
+ documentSetByAddingDocument:FSTTestDoc(util::MakeStringView([NSString
+ stringWithFormat:@"%s/%@", path.data(), key]),
+ 1, oldDocs[key], hasPendingWrites)];
}
FSTDocumentSet *newDocuments = oldDocuments;
NSArray<FSTDocumentViewChange *> *documentChanges = [NSArray array];
for (NSString *key in docsToAdd) {
- FSTDocument *docToAdd = FSTTestDoc([NSString stringWithFormat:@"%@/%@", path, key], 1,
- docsToAdd[key], hasPendingWrites);
+ FSTDocument *docToAdd =
+ FSTTestDoc(util::MakeStringView([NSString stringWithFormat:@"%s/%@", path.data(), key]), 1,
+ docsToAdd[key], hasPendingWrites);
newDocuments = [newDocuments documentSetByAddingDocument:docToAdd];
documentChanges = [documentChanges
arrayByAddingObject:[FSTDocumentViewChange
changeWithDocument:docToAdd
type:FSTDocumentViewChangeTypeAdded]];
}
- FSTViewSnapshot *viewSnapshot =
- [[FSTViewSnapshot alloc] initWithQuery:FSTTestQuery(util::MakeStringView(path))
- documents:newDocuments
- oldDocuments:oldDocuments
- documentChanges:documentChanges
- fromCache:fromCache
- hasPendingWrites:hasPendingWrites
- syncStateChanged:YES];
+ FSTViewSnapshot *viewSnapshot = [[FSTViewSnapshot alloc] initWithQuery:FSTTestQuery(path)
+ documents:newDocuments
+ oldDocuments:oldDocuments
+ documentChanges:documentChanges
+ fromCache:fromCache
+ hasPendingWrites:hasPendingWrites
+ syncStateChanged:YES];
return [FIRQuerySnapshot snapshotWithFirestore:FSTTestFirestore()
- originalQuery:FSTTestQuery(util::MakeStringView(path))
+ originalQuery:FSTTestQuery(path)
snapshot:viewSnapshot
metadata:metadata];
}
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 ]));
}
diff --git a/Firestore/Example/Tests/Local/FSTLocalSerializerTests.mm b/Firestore/Example/Tests/Local/FSTLocalSerializerTests.mm
index 87242fa..d94925d 100644
--- a/Firestore/Example/Tests/Local/FSTLocalSerializerTests.mm
+++ b/Firestore/Example/Tests/Local/FSTLocalSerializerTests.mm
@@ -126,7 +126,7 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)testEncodesDocumentAsMaybeDocument {
- FSTDocument *doc = FSTTestDoc(@"some/path", 42, @{@"foo" : @"bar"}, NO);
+ FSTDocument *doc = FSTTestDoc("some/path", 42, @{@"foo" : @"bar"}, NO);
FSTPBMaybeDocument *maybeDocProto = [FSTPBMaybeDocument message];
maybeDocProto.document = [GCFSDocument message];
@@ -143,7 +143,7 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)testEncodesDeletedDocumentAsMaybeDocument {
- FSTDeletedDocument *deletedDoc = FSTTestDeletedDoc(@"some/path", 42);
+ FSTDeletedDocument *deletedDoc = FSTTestDeletedDoc("some/path", 42);
FSTPBMaybeDocument *maybeDocProto = [FSTPBMaybeDocument message];
maybeDocProto.noDocument = [FSTPBNoDocument message];
diff --git a/Firestore/Example/Tests/Local/FSTLocalStoreTests.mm b/Firestore/Example/Tests/Local/FSTLocalStoreTests.mm
index 5a386b6..7c3b977 100644
--- a/Firestore/Example/Tests/Local/FSTLocalStoreTests.mm
+++ b/Firestore/Example/Tests/Local/FSTLocalStoreTests.mm
@@ -237,25 +237,25 @@ FSTDocumentVersionDictionary *FSTVersionDictionary(FSTMutation *mutation,
if ([self isTestBaseClass]) return;
[self writeMutation:FSTTestSetMutation(@"foo/bar", @{@"foo" : @"bar"})];
- FSTAssertChanged(@[ FSTTestDoc(@"foo/bar", 0, @{@"foo" : @"bar"}, YES) ]);
- FSTAssertContains(FSTTestDoc(@"foo/bar", 0, @{@"foo" : @"bar"}, YES));
+ FSTAssertChanged(@[ FSTTestDoc("foo/bar", 0, @{@"foo" : @"bar"}, YES) ]);
+ FSTAssertContains(FSTTestDoc("foo/bar", 0, @{@"foo" : @"bar"}, YES));
[self acknowledgeMutationWithVersion:0];
- FSTAssertChanged(@[ FSTTestDoc(@"foo/bar", 0, @{@"foo" : @"bar"}, NO) ]);
- FSTAssertContains(FSTTestDoc(@"foo/bar", 0, @{@"foo" : @"bar"}, NO));
+ FSTAssertChanged(@[ FSTTestDoc("foo/bar", 0, @{@"foo" : @"bar"}, NO) ]);
+ FSTAssertContains(FSTTestDoc("foo/bar", 0, @{@"foo" : @"bar"}, NO));
}
- (void)testHandlesSetMutationThenDocument {
if ([self isTestBaseClass]) return;
[self writeMutation:FSTTestSetMutation(@"foo/bar", @{@"foo" : @"bar"})];
- FSTAssertChanged(@[ FSTTestDoc(@"foo/bar", 0, @{@"foo" : @"bar"}, YES) ]);
- FSTAssertContains(FSTTestDoc(@"foo/bar", 0, @{@"foo" : @"bar"}, YES));
+ FSTAssertChanged(@[ FSTTestDoc("foo/bar", 0, @{@"foo" : @"bar"}, YES) ]);
+ FSTAssertContains(FSTTestDoc("foo/bar", 0, @{@"foo" : @"bar"}, YES));
[self applyRemoteEvent:FSTTestUpdateRemoteEvent(
- FSTTestDoc(@"foo/bar", 2, @{@"it" : @"changed"}, NO), @[ @1 ], @[])];
- FSTAssertChanged(@[ FSTTestDoc(@"foo/bar", 2, @{@"foo" : @"bar"}, YES) ]);
- FSTAssertContains(FSTTestDoc(@"foo/bar", 2, @{@"foo" : @"bar"}, YES));
+ FSTTestDoc("foo/bar", 2, @{@"it" : @"changed"}, NO), @[ @1 ], @[])];
+ FSTAssertChanged(@[ FSTTestDoc("foo/bar", 2, @{@"foo" : @"bar"}, YES) ]);
+ FSTAssertContains(FSTTestDoc("foo/bar", 2, @{@"foo" : @"bar"}, YES));
}
- (void)testHandlesAckThenRejectThenRemoteEvent {
@@ -266,76 +266,76 @@ FSTDocumentVersionDictionary *FSTVersionDictionary(FSTMutation *mutation,
[self allocateQuery:query];
[self writeMutation:FSTTestSetMutation(@"foo/bar", @{@"foo" : @"bar"})];
- FSTAssertChanged(@[ FSTTestDoc(@"foo/bar", 0, @{@"foo" : @"bar"}, YES) ]);
- FSTAssertContains(FSTTestDoc(@"foo/bar", 0, @{@"foo" : @"bar"}, YES));
+ FSTAssertChanged(@[ FSTTestDoc("foo/bar", 0, @{@"foo" : @"bar"}, YES) ]);
+ FSTAssertContains(FSTTestDoc("foo/bar", 0, @{@"foo" : @"bar"}, YES));
// The last seen version is zero, so this ack must be held.
[self acknowledgeMutationWithVersion:1];
FSTAssertChanged(@[]);
- FSTAssertContains(FSTTestDoc(@"foo/bar", 0, @{@"foo" : @"bar"}, YES));
+ FSTAssertContains(FSTTestDoc("foo/bar", 0, @{@"foo" : @"bar"}, YES));
[self writeMutation:FSTTestSetMutation(@"bar/baz", @{@"bar" : @"baz"})];
- FSTAssertChanged(@[ FSTTestDoc(@"bar/baz", 0, @{@"bar" : @"baz"}, YES) ]);
- FSTAssertContains(FSTTestDoc(@"bar/baz", 0, @{@"bar" : @"baz"}, YES));
+ FSTAssertChanged(@[ FSTTestDoc("bar/baz", 0, @{@"bar" : @"baz"}, YES) ]);
+ FSTAssertContains(FSTTestDoc("bar/baz", 0, @{@"bar" : @"baz"}, YES));
[self rejectMutation];
FSTAssertRemoved(@[ @"bar/baz" ]);
FSTAssertNotContains(@"bar/baz");
[self applyRemoteEvent:FSTTestUpdateRemoteEvent(
- FSTTestDoc(@"foo/bar", 2, @{@"it" : @"changed"}, NO), @[ @1 ], @[])];
- FSTAssertChanged(@[ FSTTestDoc(@"foo/bar", 2, @{@"it" : @"changed"}, NO) ]);
- FSTAssertContains(FSTTestDoc(@"foo/bar", 2, @{@"it" : @"changed"}, NO));
+ FSTTestDoc("foo/bar", 2, @{@"it" : @"changed"}, NO), @[ @1 ], @[])];
+ FSTAssertChanged(@[ FSTTestDoc("foo/bar", 2, @{@"it" : @"changed"}, NO) ]);
+ FSTAssertContains(FSTTestDoc("foo/bar", 2, @{@"it" : @"changed"}, NO));
FSTAssertNotContains(@"bar/baz");
}
- (void)testHandlesDeletedDocumentThenSetMutationThenAck {
if ([self isTestBaseClass]) return;
- [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDeletedDoc(@"foo/bar", 2), @[ @1 ], @[])];
+ [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDeletedDoc("foo/bar", 2), @[ @1 ], @[])];
FSTAssertRemoved(@[ @"foo/bar" ]);
- FSTAssertContains(FSTTestDeletedDoc(@"foo/bar", 2));
+ FSTAssertContains(FSTTestDeletedDoc("foo/bar", 2));
[self writeMutation:FSTTestSetMutation(@"foo/bar", @{@"foo" : @"bar"})];
- FSTAssertChanged(@[ FSTTestDoc(@"foo/bar", 0, @{@"foo" : @"bar"}, YES) ]);
- FSTAssertContains(FSTTestDoc(@"foo/bar", 0, @{@"foo" : @"bar"}, YES));
+ FSTAssertChanged(@[ FSTTestDoc("foo/bar", 0, @{@"foo" : @"bar"}, YES) ]);
+ FSTAssertContains(FSTTestDoc("foo/bar", 0, @{@"foo" : @"bar"}, YES));
[self acknowledgeMutationWithVersion:3];
- FSTAssertChanged(@[ FSTTestDoc(@"foo/bar", 0, @{@"foo" : @"bar"}, NO) ]);
- FSTAssertContains(FSTTestDoc(@"foo/bar", 0, @{@"foo" : @"bar"}, NO));
+ FSTAssertChanged(@[ FSTTestDoc("foo/bar", 0, @{@"foo" : @"bar"}, NO) ]);
+ FSTAssertContains(FSTTestDoc("foo/bar", 0, @{@"foo" : @"bar"}, NO));
}
- (void)testHandlesSetMutationThenDeletedDocument {
if ([self isTestBaseClass]) return;
[self writeMutation:FSTTestSetMutation(@"foo/bar", @{@"foo" : @"bar"})];
- FSTAssertChanged(@[ FSTTestDoc(@"foo/bar", 0, @{@"foo" : @"bar"}, YES) ]);
+ FSTAssertChanged(@[ FSTTestDoc("foo/bar", 0, @{@"foo" : @"bar"}, YES) ]);
- [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDeletedDoc(@"foo/bar", 2), @[ @1 ], @[])];
- FSTAssertChanged(@[ FSTTestDoc(@"foo/bar", 0, @{@"foo" : @"bar"}, YES) ]);
- FSTAssertContains(FSTTestDoc(@"foo/bar", 0, @{@"foo" : @"bar"}, YES));
+ [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDeletedDoc("foo/bar", 2), @[ @1 ], @[])];
+ FSTAssertChanged(@[ FSTTestDoc("foo/bar", 0, @{@"foo" : @"bar"}, YES) ]);
+ FSTAssertContains(FSTTestDoc("foo/bar", 0, @{@"foo" : @"bar"}, YES));
}
- (void)testHandlesDocumentThenSetMutationThenAckThenDocument {
if ([self isTestBaseClass]) return;
- [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc(@"foo/bar", 2, @{@"it" : @"base"}, NO),
+ [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc("foo/bar", 2, @{@"it" : @"base"}, NO),
@[ @1 ], @[])];
- FSTAssertChanged(@[ FSTTestDoc(@"foo/bar", 2, @{@"it" : @"base"}, NO) ]);
- FSTAssertContains(FSTTestDoc(@"foo/bar", 2, @{@"it" : @"base"}, NO));
+ FSTAssertChanged(@[ FSTTestDoc("foo/bar", 2, @{@"it" : @"base"}, NO) ]);
+ FSTAssertContains(FSTTestDoc("foo/bar", 2, @{@"it" : @"base"}, NO));
[self writeMutation:FSTTestSetMutation(@"foo/bar", @{@"foo" : @"bar"})];
- FSTAssertChanged(@[ FSTTestDoc(@"foo/bar", 2, @{@"foo" : @"bar"}, YES) ]);
- FSTAssertContains(FSTTestDoc(@"foo/bar", 2, @{@"foo" : @"bar"}, YES));
+ FSTAssertChanged(@[ FSTTestDoc("foo/bar", 2, @{@"foo" : @"bar"}, YES) ]);
+ FSTAssertContains(FSTTestDoc("foo/bar", 2, @{@"foo" : @"bar"}, YES));
[self acknowledgeMutationWithVersion:3];
- FSTAssertChanged(@[ FSTTestDoc(@"foo/bar", 2, @{@"foo" : @"bar"}, NO) ]);
- FSTAssertContains(FSTTestDoc(@"foo/bar", 2, @{@"foo" : @"bar"}, NO));
+ FSTAssertChanged(@[ FSTTestDoc("foo/bar", 2, @{@"foo" : @"bar"}, NO) ]);
+ FSTAssertContains(FSTTestDoc("foo/bar", 2, @{@"foo" : @"bar"}, NO));
[self applyRemoteEvent:FSTTestUpdateRemoteEvent(
- FSTTestDoc(@"foo/bar", 3, @{@"it" : @"changed"}, NO), @[ @1 ], @[])];
- FSTAssertChanged(@[ FSTTestDoc(@"foo/bar", 3, @{@"it" : @"changed"}, NO) ]);
- FSTAssertContains(FSTTestDoc(@"foo/bar", 3, @{@"it" : @"changed"}, NO));
+ FSTTestDoc("foo/bar", 3, @{@"it" : @"changed"}, NO), @[ @1 ], @[])];
+ FSTAssertChanged(@[ FSTTestDoc("foo/bar", 3, @{@"it" : @"changed"}, NO) ]);
+ FSTAssertContains(FSTTestDoc("foo/bar", 3, @{@"it" : @"changed"}, NO));
}
- (void)testHandlesPatchWithoutPriorDocument {
@@ -357,14 +357,14 @@ FSTDocumentVersionDictionary *FSTVersionDictionary(FSTMutation *mutation,
FSTAssertRemoved(@[ @"foo/bar" ]);
FSTAssertNotContains(@"foo/bar");
- [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc(@"foo/bar", 1, @{@"it" : @"base"}, NO),
+ [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc("foo/bar", 1, @{@"it" : @"base"}, NO),
@[ @1 ], @[])];
- FSTAssertChanged(@[ FSTTestDoc(@"foo/bar", 1, @{@"foo" : @"bar", @"it" : @"base"}, YES) ]);
- FSTAssertContains(FSTTestDoc(@"foo/bar", 1, @{@"foo" : @"bar", @"it" : @"base"}, YES));
+ FSTAssertChanged(@[ FSTTestDoc("foo/bar", 1, @{@"foo" : @"bar", @"it" : @"base"}, YES) ]);
+ FSTAssertContains(FSTTestDoc("foo/bar", 1, @{@"foo" : @"bar", @"it" : @"base"}, YES));
[self acknowledgeMutationWithVersion:2];
- FSTAssertChanged(@[ FSTTestDoc(@"foo/bar", 1, @{@"foo" : @"bar", @"it" : @"base"}, NO) ]);
- FSTAssertContains(FSTTestDoc(@"foo/bar", 1, @{@"foo" : @"bar", @"it" : @"base"}, NO));
+ FSTAssertChanged(@[ FSTTestDoc("foo/bar", 1, @{@"foo" : @"bar", @"it" : @"base"}, NO) ]);
+ FSTAssertContains(FSTTestDoc("foo/bar", 1, @{@"foo" : @"bar", @"it" : @"base"}, NO));
}
- (void)testHandlesPatchMutationThenAckThenDocument {
@@ -378,10 +378,10 @@ FSTDocumentVersionDictionary *FSTVersionDictionary(FSTMutation *mutation,
FSTAssertRemoved(@[ @"foo/bar" ]);
FSTAssertNotContains(@"foo/bar");
- [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc(@"foo/bar", 1, @{@"it" : @"base"}, NO),
+ [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc("foo/bar", 1, @{@"it" : @"base"}, NO),
@[ @1 ], @[])];
- FSTAssertChanged(@[ FSTTestDoc(@"foo/bar", 1, @{@"it" : @"base"}, NO) ]);
- FSTAssertContains(FSTTestDoc(@"foo/bar", 1, @{@"it" : @"base"}, NO));
+ FSTAssertChanged(@[ FSTTestDoc("foo/bar", 1, @{@"it" : @"base"}, NO) ]);
+ FSTAssertContains(FSTTestDoc("foo/bar", 1, @{@"it" : @"base"}, NO));
}
- (void)testHandlesDeleteMutationThenAck {
@@ -389,28 +389,28 @@ FSTDocumentVersionDictionary *FSTVersionDictionary(FSTMutation *mutation,
[self writeMutation:FSTTestDeleteMutation(@"foo/bar")];
FSTAssertRemoved(@[ @"foo/bar" ]);
- FSTAssertContains(FSTTestDeletedDoc(@"foo/bar", 0));
+ FSTAssertContains(FSTTestDeletedDoc("foo/bar", 0));
[self acknowledgeMutationWithVersion:1];
FSTAssertRemoved(@[ @"foo/bar" ]);
- FSTAssertContains(FSTTestDeletedDoc(@"foo/bar", 0));
+ FSTAssertContains(FSTTestDeletedDoc("foo/bar", 0));
}
- (void)testHandlesDocumentThenDeleteMutationThenAck {
if ([self isTestBaseClass]) return;
- [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc(@"foo/bar", 1, @{@"it" : @"base"}, NO),
+ [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc("foo/bar", 1, @{@"it" : @"base"}, NO),
@[ @1 ], @[])];
- FSTAssertChanged(@[ FSTTestDoc(@"foo/bar", 1, @{@"it" : @"base"}, NO) ]);
- FSTAssertContains(FSTTestDoc(@"foo/bar", 1, @{@"it" : @"base"}, NO));
+ FSTAssertChanged(@[ FSTTestDoc("foo/bar", 1, @{@"it" : @"base"}, NO) ]);
+ FSTAssertContains(FSTTestDoc("foo/bar", 1, @{@"it" : @"base"}, NO));
[self writeMutation:FSTTestDeleteMutation(@"foo/bar")];
FSTAssertRemoved(@[ @"foo/bar" ]);
- FSTAssertContains(FSTTestDeletedDoc(@"foo/bar", 0));
+ FSTAssertContains(FSTTestDeletedDoc("foo/bar", 0));
[self acknowledgeMutationWithVersion:2];
FSTAssertRemoved(@[ @"foo/bar" ]);
- FSTAssertContains(FSTTestDeletedDoc(@"foo/bar", 0));
+ FSTAssertContains(FSTTestDeletedDoc("foo/bar", 0));
}
- (void)testHandlesDeleteMutationThenDocumentThenAck {
@@ -418,59 +418,59 @@ FSTDocumentVersionDictionary *FSTVersionDictionary(FSTMutation *mutation,
[self writeMutation:FSTTestDeleteMutation(@"foo/bar")];
FSTAssertRemoved(@[ @"foo/bar" ]);
- FSTAssertContains(FSTTestDeletedDoc(@"foo/bar", 0));
+ FSTAssertContains(FSTTestDeletedDoc("foo/bar", 0));
- [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc(@"foo/bar", 1, @{@"it" : @"base"}, NO),
+ [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc("foo/bar", 1, @{@"it" : @"base"}, NO),
@[ @1 ], @[])];
FSTAssertRemoved(@[ @"foo/bar" ]);
- FSTAssertContains(FSTTestDeletedDoc(@"foo/bar", 0));
+ FSTAssertContains(FSTTestDeletedDoc("foo/bar", 0));
[self acknowledgeMutationWithVersion:2];
FSTAssertRemoved(@[ @"foo/bar" ]);
- FSTAssertContains(FSTTestDeletedDoc(@"foo/bar", 0));
+ FSTAssertContains(FSTTestDeletedDoc("foo/bar", 0));
}
- (void)testHandlesDocumentThenDeletedDocumentThenDocument {
if ([self isTestBaseClass]) return;
- [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc(@"foo/bar", 1, @{@"it" : @"base"}, NO),
+ [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc("foo/bar", 1, @{@"it" : @"base"}, NO),
@[ @1 ], @[])];
- FSTAssertChanged(@[ FSTTestDoc(@"foo/bar", 1, @{@"it" : @"base"}, NO) ]);
- FSTAssertContains(FSTTestDoc(@"foo/bar", 1, @{@"it" : @"base"}, NO));
+ FSTAssertChanged(@[ FSTTestDoc("foo/bar", 1, @{@"it" : @"base"}, NO) ]);
+ FSTAssertContains(FSTTestDoc("foo/bar", 1, @{@"it" : @"base"}, NO));
- [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDeletedDoc(@"foo/bar", 2), @[ @1 ], @[])];
+ [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDeletedDoc("foo/bar", 2), @[ @1 ], @[])];
FSTAssertRemoved(@[ @"foo/bar" ]);
- FSTAssertContains(FSTTestDeletedDoc(@"foo/bar", 2));
+ FSTAssertContains(FSTTestDeletedDoc("foo/bar", 2));
[self applyRemoteEvent:FSTTestUpdateRemoteEvent(
- FSTTestDoc(@"foo/bar", 3, @{@"it" : @"changed"}, NO), @[ @1 ], @[])];
- FSTAssertChanged(@[ FSTTestDoc(@"foo/bar", 3, @{@"it" : @"changed"}, NO) ]);
- FSTAssertContains(FSTTestDoc(@"foo/bar", 3, @{@"it" : @"changed"}, NO));
+ FSTTestDoc("foo/bar", 3, @{@"it" : @"changed"}, NO), @[ @1 ], @[])];
+ FSTAssertChanged(@[ FSTTestDoc("foo/bar", 3, @{@"it" : @"changed"}, NO) ]);
+ FSTAssertContains(FSTTestDoc("foo/bar", 3, @{@"it" : @"changed"}, NO));
}
- (void)testHandlesSetMutationThenPatchMutationThenDocumentThenAckThenAck {
if ([self isTestBaseClass]) return;
[self writeMutation:FSTTestSetMutation(@"foo/bar", @{@"foo" : @"old"})];
- FSTAssertChanged(@[ FSTTestDoc(@"foo/bar", 0, @{@"foo" : @"old"}, YES) ]);
- FSTAssertContains(FSTTestDoc(@"foo/bar", 0, @{@"foo" : @"old"}, YES));
+ FSTAssertChanged(@[ FSTTestDoc("foo/bar", 0, @{@"foo" : @"old"}, YES) ]);
+ FSTAssertContains(FSTTestDoc("foo/bar", 0, @{@"foo" : @"old"}, YES));
[self writeMutation:FSTTestPatchMutation("foo/bar", @{@"foo" : @"bar"}, {})];
- FSTAssertChanged(@[ FSTTestDoc(@"foo/bar", 0, @{@"foo" : @"bar"}, YES) ]);
- FSTAssertContains(FSTTestDoc(@"foo/bar", 0, @{@"foo" : @"bar"}, YES));
+ FSTAssertChanged(@[ FSTTestDoc("foo/bar", 0, @{@"foo" : @"bar"}, YES) ]);
+ FSTAssertContains(FSTTestDoc("foo/bar", 0, @{@"foo" : @"bar"}, YES));
- [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc(@"foo/bar", 1, @{@"it" : @"base"}, NO),
+ [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc("foo/bar", 1, @{@"it" : @"base"}, NO),
@[ @1 ], @[])];
- FSTAssertChanged(@[ FSTTestDoc(@"foo/bar", 1, @{@"foo" : @"bar"}, YES) ]);
- FSTAssertContains(FSTTestDoc(@"foo/bar", 1, @{@"foo" : @"bar"}, YES));
+ FSTAssertChanged(@[ FSTTestDoc("foo/bar", 1, @{@"foo" : @"bar"}, YES) ]);
+ FSTAssertContains(FSTTestDoc("foo/bar", 1, @{@"foo" : @"bar"}, YES));
[self acknowledgeMutationWithVersion:2]; // delete mutation
- FSTAssertChanged(@[ FSTTestDoc(@"foo/bar", 1, @{@"foo" : @"bar"}, YES) ]);
- FSTAssertContains(FSTTestDoc(@"foo/bar", 1, @{@"foo" : @"bar"}, YES));
+ FSTAssertChanged(@[ FSTTestDoc("foo/bar", 1, @{@"foo" : @"bar"}, YES) ]);
+ FSTAssertContains(FSTTestDoc("foo/bar", 1, @{@"foo" : @"bar"}, YES));
[self acknowledgeMutationWithVersion:3]; // patch mutation
- FSTAssertChanged(@[ FSTTestDoc(@"foo/bar", 1, @{@"foo" : @"bar"}, NO) ]);
- FSTAssertContains(FSTTestDoc(@"foo/bar", 1, @{@"foo" : @"bar"}, NO));
+ FSTAssertChanged(@[ FSTTestDoc("foo/bar", 1, @{@"foo" : @"bar"}, NO) ]);
+ FSTAssertContains(FSTTestDoc("foo/bar", 1, @{@"foo" : @"bar"}, NO));
}
- (void)testHandlesSetMutationAndPatchMutationTogether {
@@ -481,8 +481,8 @@ FSTDocumentVersionDictionary *FSTVersionDictionary(FSTMutation *mutation,
FSTTestPatchMutation("foo/bar", @{@"foo" : @"bar"}, {})
]];
- FSTAssertChanged(@[ FSTTestDoc(@"foo/bar", 0, @{@"foo" : @"bar"}, YES) ]);
- FSTAssertContains(FSTTestDoc(@"foo/bar", 0, @{@"foo" : @"bar"}, YES));
+ FSTAssertChanged(@[ FSTTestDoc("foo/bar", 0, @{@"foo" : @"bar"}, YES) ]);
+ FSTAssertContains(FSTTestDoc("foo/bar", 0, @{@"foo" : @"bar"}, YES));
}
- (void)testHandlesSetMutationThenPatchMutationThenReject {
@@ -490,14 +490,14 @@ FSTDocumentVersionDictionary *FSTVersionDictionary(FSTMutation *mutation,
[self writeMutation:FSTTestSetMutation(@"foo/bar", @{@"foo" : @"old"})];
[self acknowledgeMutationWithVersion:1];
- FSTAssertContains(FSTTestDoc(@"foo/bar", 0, @{@"foo" : @"old"}, NO));
+ FSTAssertContains(FSTTestDoc("foo/bar", 0, @{@"foo" : @"old"}, NO));
[self writeMutation:FSTTestPatchMutation("foo/bar", @{@"foo" : @"bar"}, {})];
- FSTAssertContains(FSTTestDoc(@"foo/bar", 0, @{@"foo" : @"bar"}, YES));
+ FSTAssertContains(FSTTestDoc("foo/bar", 0, @{@"foo" : @"bar"}, YES));
[self rejectMutation];
- FSTAssertChanged(@[ FSTTestDoc(@"foo/bar", 0, @{@"foo" : @"old"}, NO) ]);
- FSTAssertContains(FSTTestDoc(@"foo/bar", 0, @{@"foo" : @"old"}, NO));
+ FSTAssertChanged(@[ FSTTestDoc("foo/bar", 0, @{@"foo" : @"old"}, NO) ]);
+ FSTAssertContains(FSTTestDoc("foo/bar", 0, @{@"foo" : @"old"}, NO));
}
- (void)testHandlesSetMutationsAndPatchMutationOfJustOneTogether {
@@ -510,11 +510,11 @@ FSTDocumentVersionDictionary *FSTVersionDictionary(FSTMutation *mutation,
]];
FSTAssertChanged((@[
- FSTTestDoc(@"bar/baz", 0, @{@"bar" : @"baz"}, YES),
- FSTTestDoc(@"foo/bar", 0, @{@"foo" : @"bar"}, YES)
+ FSTTestDoc("bar/baz", 0, @{@"bar" : @"baz"}, YES),
+ FSTTestDoc("foo/bar", 0, @{@"foo" : @"bar"}, YES)
]));
- FSTAssertContains(FSTTestDoc(@"foo/bar", 0, @{@"foo" : @"bar"}, YES));
- FSTAssertContains(FSTTestDoc(@"bar/baz", 0, @{@"bar" : @"baz"}, YES));
+ FSTAssertContains(FSTTestDoc("foo/bar", 0, @{@"foo" : @"bar"}, YES));
+ FSTAssertContains(FSTTestDoc("bar/baz", 0, @{@"bar" : @"baz"}, YES));
}
- (void)testHandlesDeleteMutationThenPatchMutationThenAckThenAck {
@@ -522,31 +522,31 @@ FSTDocumentVersionDictionary *FSTVersionDictionary(FSTMutation *mutation,
[self writeMutation:FSTTestDeleteMutation(@"foo/bar")];
FSTAssertRemoved(@[ @"foo/bar" ]);
- FSTAssertContains(FSTTestDeletedDoc(@"foo/bar", 0));
+ FSTAssertContains(FSTTestDeletedDoc("foo/bar", 0));
[self writeMutation:FSTTestPatchMutation("foo/bar", @{@"foo" : @"bar"}, {})];
FSTAssertRemoved(@[ @"foo/bar" ]);
- FSTAssertContains(FSTTestDeletedDoc(@"foo/bar", 0));
+ FSTAssertContains(FSTTestDeletedDoc("foo/bar", 0));
[self acknowledgeMutationWithVersion:2]; // delete mutation
FSTAssertRemoved(@[ @"foo/bar" ]);
- FSTAssertContains(FSTTestDeletedDoc(@"foo/bar", 0));
+ FSTAssertContains(FSTTestDeletedDoc("foo/bar", 0));
[self acknowledgeMutationWithVersion:3]; // patch mutation
FSTAssertRemoved(@[ @"foo/bar" ]);
- FSTAssertContains(FSTTestDeletedDoc(@"foo/bar", 0));
+ FSTAssertContains(FSTTestDeletedDoc("foo/bar", 0));
}
- (void)testCollectsGarbageAfterChangeBatchWithNoTargetIDs {
if ([self isTestBaseClass]) return;
- [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDeletedDoc(@"foo/bar", 2), @[ @1 ], @[])];
+ [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDeletedDoc("foo/bar", 2), @[ @1 ], @[])];
FSTAssertRemoved(@[ @"foo/bar" ]);
[self collectGarbage];
FSTAssertNotContains(@"foo/bar");
- [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc(@"foo/bar", 2, @{@"foo" : @"bar"}, NO),
+ [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc("foo/bar", 2, @{@"foo" : @"bar"}, NO),
@[ @1 ], @[])];
[self collectGarbage];
FSTAssertNotContains(@"foo/bar");
@@ -559,12 +559,12 @@ FSTDocumentVersionDictionary *FSTVersionDictionary(FSTMutation *mutation,
[self allocateQuery:query];
FSTAssertTargetID(2);
- [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc(@"foo/bar", 2, @{@"foo" : @"bar"}, NO),
+ [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc("foo/bar", 2, @{@"foo" : @"bar"}, NO),
@[ @2 ], @[])];
[self collectGarbage];
- FSTAssertContains(FSTTestDoc(@"foo/bar", 2, @{@"foo" : @"bar"}, NO));
+ FSTAssertContains(FSTTestDoc("foo/bar", 2, @{@"foo" : @"bar"}, NO));
- [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc(@"foo/bar", 2, @{@"foo" : @"baz"}, NO),
+ [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc("foo/bar", 2, @{@"foo" : @"baz"}, NO),
@[], @[ @2 ])];
[self collectGarbage];
@@ -574,27 +574,27 @@ FSTDocumentVersionDictionary *FSTVersionDictionary(FSTMutation *mutation,
- (void)testCollectsGarbageAfterAcknowledgedMutation {
if ([self isTestBaseClass]) return;
- [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc(@"foo/bar", 0, @{@"foo" : @"old"}, NO),
+ [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc("foo/bar", 0, @{@"foo" : @"old"}, NO),
@[ @1 ], @[])];
[self writeMutation:FSTTestPatchMutation("foo/bar", @{@"foo" : @"bar"}, {})];
[self writeMutation:FSTTestSetMutation(@"foo/bah", @{@"foo" : @"bah"})];
[self writeMutation:FSTTestDeleteMutation(@"foo/baz")];
[self collectGarbage];
- FSTAssertContains(FSTTestDoc(@"foo/bar", 0, @{@"foo" : @"bar"}, YES));
- FSTAssertContains(FSTTestDoc(@"foo/bah", 0, @{@"foo" : @"bah"}, YES));
- FSTAssertContains(FSTTestDeletedDoc(@"foo/baz", 0));
+ FSTAssertContains(FSTTestDoc("foo/bar", 0, @{@"foo" : @"bar"}, YES));
+ FSTAssertContains(FSTTestDoc("foo/bah", 0, @{@"foo" : @"bah"}, YES));
+ FSTAssertContains(FSTTestDeletedDoc("foo/baz", 0));
[self acknowledgeMutationWithVersion:3];
[self collectGarbage];
FSTAssertNotContains(@"foo/bar");
- FSTAssertContains(FSTTestDoc(@"foo/bah", 0, @{@"foo" : @"bah"}, YES));
- FSTAssertContains(FSTTestDeletedDoc(@"foo/baz", 0));
+ FSTAssertContains(FSTTestDoc("foo/bah", 0, @{@"foo" : @"bah"}, YES));
+ FSTAssertContains(FSTTestDeletedDoc("foo/baz", 0));
[self acknowledgeMutationWithVersion:4];
[self collectGarbage];
FSTAssertNotContains(@"foo/bar");
FSTAssertNotContains(@"foo/bah");
- FSTAssertContains(FSTTestDeletedDoc(@"foo/baz", 0));
+ FSTAssertContains(FSTTestDeletedDoc("foo/baz", 0));
[self acknowledgeMutationWithVersion:5];
[self collectGarbage];
@@ -606,27 +606,27 @@ FSTDocumentVersionDictionary *FSTVersionDictionary(FSTMutation *mutation,
- (void)testCollectsGarbageAfterRejectedMutation {
if ([self isTestBaseClass]) return;
- [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc(@"foo/bar", 0, @{@"foo" : @"old"}, NO),
+ [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc("foo/bar", 0, @{@"foo" : @"old"}, NO),
@[ @1 ], @[])];
[self writeMutation:FSTTestPatchMutation("foo/bar", @{@"foo" : @"bar"}, {})];
[self writeMutation:FSTTestSetMutation(@"foo/bah", @{@"foo" : @"bah"})];
[self writeMutation:FSTTestDeleteMutation(@"foo/baz")];
[self collectGarbage];
- FSTAssertContains(FSTTestDoc(@"foo/bar", 0, @{@"foo" : @"bar"}, YES));
- FSTAssertContains(FSTTestDoc(@"foo/bah", 0, @{@"foo" : @"bah"}, YES));
- FSTAssertContains(FSTTestDeletedDoc(@"foo/baz", 0));
+ FSTAssertContains(FSTTestDoc("foo/bar", 0, @{@"foo" : @"bar"}, YES));
+ FSTAssertContains(FSTTestDoc("foo/bah", 0, @{@"foo" : @"bah"}, YES));
+ FSTAssertContains(FSTTestDeletedDoc("foo/baz", 0));
[self rejectMutation]; // patch mutation
[self collectGarbage];
FSTAssertNotContains(@"foo/bar");
- FSTAssertContains(FSTTestDoc(@"foo/bah", 0, @{@"foo" : @"bah"}, YES));
- FSTAssertContains(FSTTestDeletedDoc(@"foo/baz", 0));
+ FSTAssertContains(FSTTestDoc("foo/bah", 0, @{@"foo" : @"bah"}, YES));
+ FSTAssertContains(FSTTestDeletedDoc("foo/baz", 0));
[self rejectMutation]; // set mutation
[self collectGarbage];
FSTAssertNotContains(@"foo/bar");
FSTAssertNotContains(@"foo/bah");
- FSTAssertContains(FSTTestDeletedDoc(@"foo/baz", 0));
+ FSTAssertContains(FSTTestDeletedDoc("foo/baz", 0));
[self rejectMutation]; // delete mutation
[self collectGarbage];
@@ -642,22 +642,22 @@ FSTDocumentVersionDictionary *FSTVersionDictionary(FSTMutation *mutation,
[self allocateQuery:query];
FSTAssertTargetID(2);
- [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc(@"foo/bar", 1, @{@"foo" : @"bar"}, NO),
+ [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc("foo/bar", 1, @{@"foo" : @"bar"}, NO),
@[ @2 ], @[])];
[self writeMutation:FSTTestSetMutation(@"foo/baz", @{@"foo" : @"baz"})];
[self collectGarbage];
- FSTAssertContains(FSTTestDoc(@"foo/bar", 1, @{@"foo" : @"bar"}, NO));
- FSTAssertContains(FSTTestDoc(@"foo/baz", 0, @{@"foo" : @"baz"}, YES));
+ FSTAssertContains(FSTTestDoc("foo/bar", 1, @{@"foo" : @"bar"}, NO));
+ FSTAssertContains(FSTTestDoc("foo/baz", 0, @{@"foo" : @"baz"}, YES));
[self notifyLocalViewChanges:FSTTestViewChanges(query, @[ @"foo/bar", @"foo/baz" ], @[])];
- [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc(@"foo/bar", 1, @{@"foo" : @"bar"}, NO),
+ [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc("foo/bar", 1, @{@"foo" : @"bar"}, NO),
@[], @[ @2 ])];
- [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc(@"foo/baz", 2, @{@"foo" : @"baz"}, NO),
+ [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc("foo/baz", 2, @{@"foo" : @"baz"}, NO),
@[ @1 ], @[])];
[self acknowledgeMutationWithVersion:2];
[self collectGarbage];
- FSTAssertContains(FSTTestDoc(@"foo/bar", 1, @{@"foo" : @"bar"}, NO));
- FSTAssertContains(FSTTestDoc(@"foo/baz", 2, @{@"foo" : @"baz"}, NO));
+ FSTAssertContains(FSTTestDoc("foo/bar", 1, @{@"foo" : @"bar"}, NO));
+ FSTAssertContains(FSTTestDoc("foo/baz", 2, @{@"foo" : @"baz"}, NO));
[self notifyLocalViewChanges:FSTTestViewChanges(query, @[], @[ @"foo/bar", @"foo/baz" ])];
[self collectGarbage];
@@ -670,9 +670,9 @@ FSTDocumentVersionDictionary *FSTVersionDictionary(FSTMutation *mutation,
if ([self isTestBaseClass]) return;
FSTTargetID targetID = 321;
- [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc(@"foo/bar", 1, @{}, NO),
+ [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc("foo/bar", 1, @{}, NO),
@[ @(targetID) ], @[])];
- FSTAssertContains(FSTTestDoc(@"foo/bar", 1, @{}, NO));
+ FSTAssertContains(FSTTestDoc("foo/bar", 1, @{}, NO));
[self collectGarbage];
FSTAssertNotContains(@"foo/bar");
@@ -688,7 +688,7 @@ FSTDocumentVersionDictionary *FSTVersionDictionary(FSTMutation *mutation,
]];
FSTQuery *query = FSTTestQuery("foo/bar");
FSTDocumentDictionary *docs = [self.localStore executeQuery:query];
- XCTAssertEqualObjects([docs values], @[ FSTTestDoc(@"foo/bar", 0, @{@"foo" : @"bar"}, YES) ]);
+ XCTAssertEqualObjects([docs values], @[ FSTTestDoc("foo/bar", 0, @{@"foo" : @"bar"}, YES) ]);
}
- (void)testCanExecuteCollectionQueries {
@@ -704,8 +704,8 @@ FSTDocumentVersionDictionary *FSTVersionDictionary(FSTMutation *mutation,
FSTQuery *query = FSTTestQuery("foo");
FSTDocumentDictionary *docs = [self.localStore executeQuery:query];
XCTAssertEqualObjects([docs values], (@[
- FSTTestDoc(@"foo/bar", 0, @{@"foo" : @"bar"}, YES),
- FSTTestDoc(@"foo/baz", 0, @{@"foo" : @"baz"}, YES)
+ FSTTestDoc("foo/bar", 0, @{@"foo" : @"bar"}, YES),
+ FSTTestDoc("foo/baz", 0, @{@"foo" : @"baz"}, YES)
]));
}
@@ -716,18 +716,18 @@ FSTDocumentVersionDictionary *FSTVersionDictionary(FSTMutation *mutation,
[self allocateQuery:query];
FSTAssertTargetID(2);
- [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc(@"foo/baz", 10, @{@"a" : @"b"}, NO),
+ [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc("foo/baz", 10, @{@"a" : @"b"}, NO),
@[ @2 ], @[])];
- [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc(@"foo/bar", 20, @{@"a" : @"b"}, NO),
+ [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc("foo/bar", 20, @{@"a" : @"b"}, NO),
@[ @2 ], @[])];
[self.localStore locallyWriteMutations:@[ FSTTestSetMutation(@"foo/bonk", @{@"a" : @"b"}) ]];
FSTDocumentDictionary *docs = [self.localStore executeQuery:query];
XCTAssertEqualObjects([docs values], (@[
- FSTTestDoc(@"foo/bar", 20, @{@"a" : @"b"}, NO),
- FSTTestDoc(@"foo/baz", 10, @{@"a" : @"b"}, NO),
- FSTTestDoc(@"foo/bonk", 0, @{@"a" : @"b"}, YES)
+ FSTTestDoc("foo/bar", 20, @{@"a" : @"b"}, NO),
+ FSTTestDoc("foo/baz", 10, @{@"a" : @"b"}, NO),
+ FSTTestDoc("foo/bonk", 0, @{@"a" : @"b"}, YES)
]));
}
@@ -775,9 +775,9 @@ FSTDocumentVersionDictionary *FSTVersionDictionary(FSTMutation *mutation,
[self allocateQuery:query];
FSTAssertTargetID(2);
- [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc(@"foo/baz", 10, @{@"a" : @"b"}, NO),
+ [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc("foo/baz", 10, @{@"a" : @"b"}, NO),
@[ @2 ], @[])];
- [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc(@"foo/bar", 20, @{@"a" : @"b"}, NO),
+ [self applyRemoteEvent:FSTTestUpdateRemoteEvent(FSTTestDoc("foo/bar", 20, @{@"a" : @"b"}, NO),
@[ @2 ], @[])];
[self.localStore locallyWriteMutations:@[ FSTTestSetMutation(@"foo/bonk", @{@"a" : @"b"}) ]];
diff --git a/Firestore/Example/Tests/Local/FSTRemoteDocumentCacheTests.mm b/Firestore/Example/Tests/Local/FSTRemoteDocumentCacheTests.mm
index d056488..16b7185 100644
--- a/Firestore/Example/Tests/Local/FSTRemoteDocumentCacheTests.mm
+++ b/Firestore/Example/Tests/Local/FSTRemoteDocumentCacheTests.mm
@@ -25,10 +25,17 @@
#import "Firestore/Example/Tests/Util/FSTHelpers.h"
+#include "Firestore/core/src/firebase/firestore/util/string_apple.h"
+#include "Firestore/core/test/firebase/firestore/testutil/testutil.h"
+#include "absl/strings/string_view.h"
+
+namespace testutil = firebase::firestore::testutil;
+namespace util = firebase::firestore::util;
+
NS_ASSUME_NONNULL_BEGIN
-static NSString *const kDocPath = @"a/b";
-static NSString *const kLongDocPath = @"a/b/c/d/e/f";
+static const char *kDocPath = "a/b";
+static const char *kLongDocPath = "a/b/c/d/e/f";
static const int kVersion = 42;
@implementation FSTRemoteDocumentCacheTests {
@@ -49,7 +56,7 @@ static const int kVersion = 42;
}
// Helper for next two tests.
-- (void)setAndReadADocumentAtPath:(NSString *)path {
+- (void)setAndReadADocumentAtPath:(const absl::string_view)path {
FSTDocument *written = [self setTestDocumentAtPath:path];
FSTMaybeDocument *read = [self readEntryAtPath:path];
XCTAssertEqualObjects(read, written);
@@ -107,15 +114,15 @@ static const int kVersion = 42;
// TODO(rsgowman): This just verifies that we do a prefix scan against the
// query path. We'll need more tests once we add index support.
- [self setTestDocumentAtPath:@"a/1"];
- [self setTestDocumentAtPath:@"b/1"];
- [self setTestDocumentAtPath:@"b/2"];
- [self setTestDocumentAtPath:@"c/1"];
+ [self setTestDocumentAtPath:"a/1"];
+ [self setTestDocumentAtPath:"b/1"];
+ [self setTestDocumentAtPath:"b/2"];
+ [self setTestDocumentAtPath:"c/1"];
FSTQuery *query = FSTTestQuery("b");
FSTDocumentDictionary *results = [self.remoteDocumentCache documentsMatchingQuery:query];
NSArray *expected =
- @[ FSTTestDoc(@"b/1", kVersion, _kDocData, NO), FSTTestDoc(@"b/2", kVersion, _kDocData, NO) ];
+ @[ FSTTestDoc("b/1", kVersion, _kDocData, NO), FSTTestDoc("b/2", kVersion, _kDocData, NO) ];
XCTAssertEqual([results count], [expected count]);
for (FSTDocument *doc in expected) {
XCTAssertEqualObjects([results objectForKey:doc.key], doc);
@@ -124,7 +131,7 @@ static const int kVersion = 42;
#pragma mark - Helpers
-- (FSTDocument *)setTestDocumentAtPath:(NSString *)path {
+- (FSTDocument *)setTestDocumentAtPath:(const absl::string_view)path {
FSTDocument *doc = FSTTestDoc(path, kVersion, _kDocData, NO);
[self addEntry:doc];
return doc;
@@ -136,13 +143,13 @@ static const int kVersion = 42;
[self.persistence commitGroup:group];
}
-- (FSTMaybeDocument *_Nullable)readEntryAtPath:(NSString *)path {
- return [self.remoteDocumentCache entryForKey:FSTTestDocKey(path)];
+- (FSTMaybeDocument *_Nullable)readEntryAtPath:(const absl::string_view)path {
+ return [self.remoteDocumentCache entryForKey:testutil::Key(path)];
}
-- (void)removeEntryAtPath:(NSString *)path {
+- (void)removeEntryAtPath:(const absl::string_view)path {
FSTWriteGroup *group = [self.persistence startGroupWithAction:@"removeEntryAtPath"];
- [self.remoteDocumentCache removeEntryForKey:FSTTestDocKey(path) group:group];
+ [self.remoteDocumentCache removeEntryForKey:testutil::Key(path) group:group];
[self.persistence commitGroup:group];
}
diff --git a/Firestore/Example/Tests/Local/FSTRemoteDocumentChangeBufferTests.mm b/Firestore/Example/Tests/Local/FSTRemoteDocumentChangeBufferTests.mm
index 1970779..36d3661 100644
--- a/Firestore/Example/Tests/Local/FSTRemoteDocumentChangeBufferTests.mm
+++ b/Firestore/Example/Tests/Local/FSTRemoteDocumentChangeBufferTests.mm
@@ -47,7 +47,7 @@ NS_ASSUME_NONNULL_BEGIN
// Add a couple initial items to the cache.
FSTWriteGroup *group = [_db startGroupWithAction:@"Add initial docs."];
- _kInitialADoc = FSTTestDoc(@"coll/a", 42, @{@"test" : @"data"}, NO);
+ _kInitialADoc = FSTTestDoc("coll/a", 42, @{@"test" : @"data"}, NO);
[_remoteDocumentCache addEntry:_kInitialADoc group:group];
_kInitialBDoc =
@@ -73,7 +73,7 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)testAddEntryAndReadItBack {
- FSTMaybeDocument *newADoc = FSTTestDoc(@"coll/a", 43, @{@"new" : @"data"}, NO);
+ FSTMaybeDocument *newADoc = FSTTestDoc("coll/a", 43, @{@"new" : @"data"}, NO);
[_remoteDocumentBuffer addEntry:newADoc];
XCTAssertEqualObjects([_remoteDocumentBuffer entryForKey:FSTTestDocKey(@"coll/a")], newADoc);
@@ -83,7 +83,7 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)testApplyChanges {
- FSTMaybeDocument *newADoc = FSTTestDoc(@"coll/a", 43, @{@"new" : @"data"}, NO);
+ FSTMaybeDocument *newADoc = FSTTestDoc("coll/a", 43, @{@"new" : @"data"}, NO);
[_remoteDocumentBuffer addEntry:newADoc];
XCTAssertEqualObjects([_remoteDocumentBuffer entryForKey:FSTTestDocKey(@"coll/a")], newADoc);
diff --git a/Firestore/Example/Tests/Model/FSTDocumentSetTests.mm b/Firestore/Example/Tests/Model/FSTDocumentSetTests.mm
index d70c44d..65c4ddf 100644
--- a/Firestore/Example/Tests/Model/FSTDocumentSetTests.mm
+++ b/Firestore/Example/Tests/Model/FSTDocumentSetTests.mm
@@ -38,9 +38,9 @@ NS_ASSUME_NONNULL_BEGIN
[super setUp];
_comp = FSTTestDocComparator("sort");
- _doc1 = FSTTestDoc(@"docs/1", 0, @{ @"sort" : @2 }, NO);
- _doc2 = FSTTestDoc(@"docs/2", 0, @{ @"sort" : @3 }, NO);
- _doc3 = FSTTestDoc(@"docs/3", 0, @{ @"sort" : @1 }, NO);
+ _doc1 = FSTTestDoc("docs/1", 0, @{ @"sort" : @2 }, NO);
+ _doc2 = FSTTestDoc("docs/2", 0, @{ @"sort" : @3 }, NO);
+ _doc3 = FSTTestDoc("docs/3", 0, @{ @"sort" : @1 }, NO);
}
- (void)testCount {
@@ -97,7 +97,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)testUpdates {
FSTDocumentSet *set = FSTTestDocSet(_comp, @[ _doc1, _doc2, _doc3 ]);
- FSTDocument *doc2Prime = FSTTestDoc(@"docs/2", 0, @{ @"sort" : @9 }, NO);
+ FSTDocument *doc2Prime = FSTTestDoc("docs/2", 0, @{ @"sort" : @9 }, NO);
set = [set documentSetByAddingDocument:doc2Prime];
XCTAssertEqual([set count], 3);
@@ -106,7 +106,7 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)testAddsDocsWithEqualComparisonValues {
- FSTDocument *doc4 = FSTTestDoc(@"docs/4", 0, @{ @"sort" : @2 }, NO);
+ FSTDocument *doc4 = FSTTestDoc("docs/4", 0, @{ @"sort" : @2 }, NO);
FSTDocumentSet *set = FSTTestDocSet(_comp, @[ _doc1, doc4 ]);
XCTAssertEqualObjects([[set documentEnumerator] allObjects], (@[ _doc1, doc4 ]));
diff --git a/Firestore/Example/Tests/Model/FSTDocumentTests.mm b/Firestore/Example/Tests/Model/FSTDocumentTests.mm
index 0527852..24858c5 100644
--- a/Firestore/Example/Tests/Model/FSTDocumentTests.mm
+++ b/Firestore/Example/Tests/Model/FSTDocumentTests.mm
@@ -19,14 +19,15 @@
#import <XCTest/XCTest.h>
#import "Firestore/Source/Core/FSTSnapshotVersion.h"
-#import "Firestore/Source/Model/FSTDocumentKey.h"
#import "Firestore/Source/Model/FSTFieldValue.h"
#import "Firestore/Example/Tests/Util/FSTHelpers.h"
+#include "Firestore/core/src/firebase/firestore/model/document_key.h"
#include "Firestore/core/test/firebase/firestore/testutil/testutil.h"
namespace testutil = firebase::firestore::testutil;
+using firebase::firestore::model::DocumentKey;
NS_ASSUME_NONNULL_BEGIN
@@ -36,7 +37,7 @@ NS_ASSUME_NONNULL_BEGIN
@implementation FSTDocumentTests
- (void)testConstructor {
- FSTDocumentKey *key = FSTTestDocKey(@"messages/first");
+ DocumentKey key = testutil::Key("messages/first");
FSTSnapshotVersion *version = FSTTestVersion(1);
FSTObjectValue *data = FSTTestObjectValue(@{ @"a" : @1 });
FSTDocument *doc =
@@ -49,7 +50,7 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)testExtractsFields {
- FSTDocumentKey *key = FSTTestDocKey(@"rooms/eros");
+ DocumentKey key = testutil::Key("rooms/eros");
FSTSnapshotVersion *version = FSTTestVersion(1);
FSTObjectValue *data = FSTTestObjectValue(@{
@"desc" : @"Discuss all the project related stuff",
@@ -65,30 +66,30 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)testIsEqual {
- XCTAssertEqualObjects(FSTTestDoc(@"messages/first", 1,
+ XCTAssertEqualObjects(FSTTestDoc("messages/first", 1,
@{ @"a" : @1 }, NO),
- FSTTestDoc(@"messages/first", 1,
+ FSTTestDoc("messages/first", 1,
@{ @"a" : @1 }, NO));
- XCTAssertNotEqualObjects(FSTTestDoc(@"messages/first", 1,
+ XCTAssertNotEqualObjects(FSTTestDoc("messages/first", 1,
@{ @"a" : @1 }, NO),
- FSTTestDoc(@"messages/first", 1,
+ FSTTestDoc("messages/first", 1,
@{ @"b" : @1 }, NO));
- XCTAssertNotEqualObjects(FSTTestDoc(@"messages/first", 1,
+ XCTAssertNotEqualObjects(FSTTestDoc("messages/first", 1,
@{ @"a" : @1 }, NO),
- FSTTestDoc(@"messages/second", 1,
+ FSTTestDoc("messages/second", 1,
@{ @"b" : @1 }, NO));
- XCTAssertNotEqualObjects(FSTTestDoc(@"messages/first", 1,
+ XCTAssertNotEqualObjects(FSTTestDoc("messages/first", 1,
@{ @"a" : @1 }, NO),
- FSTTestDoc(@"messages/first", 2,
+ FSTTestDoc("messages/first", 2,
@{ @"a" : @1 }, NO));
- XCTAssertNotEqualObjects(FSTTestDoc(@"messages/first", 1,
+ XCTAssertNotEqualObjects(FSTTestDoc("messages/first", 1,
@{ @"a" : @1 }, NO),
- FSTTestDoc(@"messages/first", 1,
+ FSTTestDoc("messages/first", 1,
@{ @"a" : @1 }, YES));
- XCTAssertEqualObjects(FSTTestDoc(@"messages/first", 1,
+ XCTAssertEqualObjects(FSTTestDoc("messages/first", 1,
@{ @"a" : @1 }, YES),
- FSTTestDoc(@"messages/first", 1,
+ FSTTestDoc("messages/first", 1,
@{ @"a" : @1 }, 5));
}
diff --git a/Firestore/Example/Tests/Model/FSTMutationTests.mm b/Firestore/Example/Tests/Model/FSTMutationTests.mm
index 5b056fb..40ded40 100644
--- a/Firestore/Example/Tests/Model/FSTMutationTests.mm
+++ b/Firestore/Example/Tests/Model/FSTMutationTests.mm
@@ -20,14 +20,15 @@
#import <XCTest/XCTest.h>
#import "Firestore/Source/Model/FSTDocument.h"
-#import "Firestore/Source/Model/FSTDocumentKey.h"
#import "Firestore/Source/Model/FSTFieldValue.h"
#import "Firestore/Example/Tests/Util/FSTHelpers.h"
+#include "Firestore/core/src/firebase/firestore/model/document_key.h"
#include "Firestore/core/test/firebase/firestore/testutil/testutil.h"
namespace testutil = firebase::firestore::testutil;
+using firebase::firestore::model::DocumentKey;
@interface FSTMutationTests : XCTestCase
@end
@@ -42,32 +43,32 @@ namespace testutil = firebase::firestore::testutil;
- (void)testAppliesSetsToDocuments {
NSDictionary *docData = @{@"foo" : @"foo-value", @"baz" : @"baz-value"};
- FSTDocument *baseDoc = FSTTestDoc(@"collection/key", 0, docData, NO);
+ FSTDocument *baseDoc = FSTTestDoc("collection/key", 0, docData, NO);
FSTMutation *set = FSTTestSetMutation(@"collection/key", @{@"bar" : @"bar-value"});
FSTMaybeDocument *setDoc = [set applyTo:baseDoc baseDocument:baseDoc localWriteTime:_timestamp];
NSDictionary *expectedData = @{@"bar" : @"bar-value"};
- XCTAssertEqualObjects(setDoc, FSTTestDoc(@"collection/key", 0, expectedData, YES));
+ XCTAssertEqualObjects(setDoc, FSTTestDoc("collection/key", 0, expectedData, YES));
}
- (void)testAppliesPatchesToDocuments {
NSDictionary *docData = @{ @"foo" : @{@"bar" : @"bar-value"}, @"baz" : @"baz-value" };
- FSTDocument *baseDoc = FSTTestDoc(@"collection/key", 0, docData, NO);
+ FSTDocument *baseDoc = FSTTestDoc("collection/key", 0, docData, NO);
FSTMutation *patch = FSTTestPatchMutation("collection/key", @{@"foo.bar" : @"new-bar-value"}, {});
FSTMaybeDocument *patchedDoc =
[patch applyTo:baseDoc baseDocument:baseDoc localWriteTime:_timestamp];
NSDictionary *expectedData = @{ @"foo" : @{@"bar" : @"new-bar-value"}, @"baz" : @"baz-value" };
- XCTAssertEqualObjects(patchedDoc, FSTTestDoc(@"collection/key", 0, expectedData, YES));
+ XCTAssertEqualObjects(patchedDoc, FSTTestDoc("collection/key", 0, expectedData, YES));
}
- (void)testDeletesValuesFromTheFieldMask {
NSDictionary *docData = @{ @"foo" : @{@"bar" : @"bar-value", @"baz" : @"baz-value"} };
- FSTDocument *baseDoc = FSTTestDoc(@"collection/key", 0, docData, NO);
+ FSTDocument *baseDoc = FSTTestDoc("collection/key", 0, docData, NO);
- FSTDocumentKey *key = FSTTestDocKey(@"collection/key");
+ DocumentKey key = testutil::Key("collection/key");
FSTFieldMask *mask = [[FSTFieldMask alloc] initWithFields:{testutil::Field("foo.bar")}];
FSTMutation *patch = [[FSTPatchMutation alloc] initWithKey:key
fieldMask:mask
@@ -77,23 +78,23 @@ namespace testutil = firebase::firestore::testutil;
[patch applyTo:baseDoc baseDocument:baseDoc localWriteTime:_timestamp];
NSDictionary *expectedData = @{ @"foo" : @{@"baz" : @"baz-value"} };
- XCTAssertEqualObjects(patchedDoc, FSTTestDoc(@"collection/key", 0, expectedData, YES));
+ XCTAssertEqualObjects(patchedDoc, FSTTestDoc("collection/key", 0, expectedData, YES));
}
- (void)testPatchesPrimitiveValue {
NSDictionary *docData = @{@"foo" : @"foo-value", @"baz" : @"baz-value"};
- FSTDocument *baseDoc = FSTTestDoc(@"collection/key", 0, docData, NO);
+ FSTDocument *baseDoc = FSTTestDoc("collection/key", 0, docData, NO);
FSTMutation *patch = FSTTestPatchMutation("collection/key", @{@"foo.bar" : @"new-bar-value"}, {});
FSTMaybeDocument *patchedDoc =
[patch applyTo:baseDoc baseDocument:baseDoc localWriteTime:_timestamp];
NSDictionary *expectedData = @{ @"foo" : @{@"bar" : @"new-bar-value"}, @"baz" : @"baz-value" };
- XCTAssertEqualObjects(patchedDoc, FSTTestDoc(@"collection/key", 0, expectedData, YES));
+ XCTAssertEqualObjects(patchedDoc, FSTTestDoc("collection/key", 0, expectedData, YES));
}
- (void)testPatchingDeletedDocumentsDoesNothing {
- FSTMaybeDocument *baseDoc = FSTTestDeletedDoc(@"collection/key", 0);
+ FSTMaybeDocument *baseDoc = FSTTestDeletedDoc("collection/key", 0);
FSTMutation *patch = FSTTestPatchMutation("collection/key", @{@"foo" : @"bar"}, {});
FSTMaybeDocument *patchedDoc =
[patch applyTo:baseDoc baseDocument:baseDoc localWriteTime:_timestamp];
@@ -102,7 +103,7 @@ namespace testutil = firebase::firestore::testutil;
- (void)testAppliesLocalTransformsToDocuments {
NSDictionary *docData = @{ @"foo" : @{@"bar" : @"bar-value"}, @"baz" : @"baz-value" };
- FSTDocument *baseDoc = FSTTestDoc(@"collection/key", 0, docData, NO);
+ FSTDocument *baseDoc = FSTTestDoc("collection/key", 0, docData, NO);
FSTMutation *transform = FSTTestTransformMutation(@"collection/key", @[ @"foo.bar" ]);
FSTMaybeDocument *transformedDoc =
@@ -128,7 +129,7 @@ namespace testutil = firebase::firestore::testutil;
- (void)testAppliesServerAckedTransformsToDocuments {
NSDictionary *docData = @{ @"foo" : @{@"bar" : @"bar-value"}, @"baz" : @"baz-value" };
- FSTDocument *baseDoc = FSTTestDoc(@"collection/key", 0, docData, NO);
+ FSTDocument *baseDoc = FSTTestDoc("collection/key", 0, docData, NO);
FSTMutation *transform = FSTTestTransformMutation(@"collection/key", @[ @"foo.bar" ]);
@@ -144,22 +145,22 @@ namespace testutil = firebase::firestore::testutil;
NSDictionary *expectedData =
@{ @"foo" : @{@"bar" : _timestamp.approximateDateValue},
@"baz" : @"baz-value" };
- XCTAssertEqualObjects(transformedDoc, FSTTestDoc(@"collection/key", 0, expectedData, NO));
+ XCTAssertEqualObjects(transformedDoc, FSTTestDoc("collection/key", 0, expectedData, NO));
}
- (void)testDeleteDeletes {
NSDictionary *docData = @{@"foo" : @"bar"};
- FSTDocument *baseDoc = FSTTestDoc(@"collection/key", 0, docData, NO);
+ FSTDocument *baseDoc = FSTTestDoc("collection/key", 0, docData, NO);
FSTMutation *mutation = FSTTestDeleteMutation(@"collection/key");
FSTMaybeDocument *result =
[mutation applyTo:baseDoc baseDocument:baseDoc localWriteTime:_timestamp];
- XCTAssertEqualObjects(result, FSTTestDeletedDoc(@"collection/key", 0));
+ XCTAssertEqualObjects(result, FSTTestDeletedDoc("collection/key", 0));
}
- (void)testSetWithMutationResult {
NSDictionary *docData = @{@"foo" : @"bar"};
- FSTDocument *baseDoc = FSTTestDoc(@"collection/key", 0, docData, NO);
+ FSTDocument *baseDoc = FSTTestDoc("collection/key", 0, docData, NO);
FSTMutation *set = FSTTestSetMutation(@"collection/key", @{@"foo" : @"new-bar"});
FSTMutationResult *mutationResult =
@@ -170,12 +171,12 @@ namespace testutil = firebase::firestore::testutil;
mutationResult:mutationResult];
NSDictionary *expectedData = @{@"foo" : @"new-bar"};
- XCTAssertEqualObjects(setDoc, FSTTestDoc(@"collection/key", 0, expectedData, NO));
+ XCTAssertEqualObjects(setDoc, FSTTestDoc("collection/key", 0, expectedData, NO));
}
- (void)testPatchWithMutationResult {
NSDictionary *docData = @{@"foo" : @"bar"};
- FSTDocument *baseDoc = FSTTestDoc(@"collection/key", 0, docData, NO);
+ FSTDocument *baseDoc = FSTTestDoc("collection/key", 0, docData, NO);
FSTMutation *patch = FSTTestPatchMutation("collection/key", @{@"foo" : @"new-bar"}, {});
FSTMutationResult *mutationResult =
@@ -186,7 +187,7 @@ namespace testutil = firebase::firestore::testutil;
mutationResult:mutationResult];
NSDictionary *expectedData = @{@"foo" : @"new-bar"};
- XCTAssertEqualObjects(patchedDoc, FSTTestDoc(@"collection/key", 0, expectedData, NO));
+ XCTAssertEqualObjects(patchedDoc, FSTTestDoc("collection/key", 0, expectedData, NO));
}
#define ASSERT_VERSION_TRANSITION(mutation, base, expected) \
@@ -204,11 +205,11 @@ namespace testutil = firebase::firestore::testutil;
* Tests the transition table documented in FSTMutation.h.
*/
- (void)testTransitions {
- FSTDocument *docV0 = FSTTestDoc(@"collection/key", 0, @{}, NO);
- FSTDeletedDocument *deletedV0 = FSTTestDeletedDoc(@"collection/key", 0);
+ FSTDocument *docV0 = FSTTestDoc("collection/key", 0, @{}, NO);
+ FSTDeletedDocument *deletedV0 = FSTTestDeletedDoc("collection/key", 0);
- FSTDocument *docV3 = FSTTestDoc(@"collection/key", 3, @{}, NO);
- FSTDeletedDocument *deletedV3 = FSTTestDeletedDoc(@"collection/key", 3);
+ FSTDocument *docV3 = FSTTestDoc("collection/key", 3, @{}, NO);
+ FSTDeletedDocument *deletedV3 = FSTTestDeletedDoc("collection/key", 3);
FSTMutation *setMutation = FSTTestSetMutation(@"collection/key", @{});
FSTMutation *patchMutation = FSTTestPatchMutation("collection/key", {}, {});
diff --git a/Firestore/Example/Tests/Remote/FSTRemoteEventTests.mm b/Firestore/Example/Tests/Remote/FSTRemoteEventTests.mm
index a947eb4..9fa8bc3 100644
--- a/Firestore/Example/Tests/Remote/FSTRemoteEventTests.mm
+++ b/Firestore/Example/Tests/Remote/FSTRemoteEventTests.mm
@@ -60,8 +60,8 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)testWillAccumulateDocumentAddedAndRemovedEvents {
- FSTDocument *doc1 = FSTTestDoc(@"docs/1", 1, @{ @"value" : @1 }, NO);
- FSTDocument *doc2 = FSTTestDoc(@"docs/2", 2, @{ @"value" : @2 }, NO);
+ FSTDocument *doc1 = FSTTestDoc("docs/1", 1, @{ @"value" : @1 }, NO);
+ FSTDocument *doc2 = FSTTestDoc("docs/2", 2, @{ @"value" : @2 }, NO);
FSTWatchChange *change1 = [[FSTDocumentWatchChange alloc] initWithUpdatedTargetIDs:@[ @1, @2, @3 ]
removedTargetIDs:@[ @4, @5, @6 ]
@@ -80,8 +80,8 @@ NS_ASSUME_NONNULL_BEGIN
FSTRemoteEvent *event = [aggregator remoteEvent];
XCTAssertEqualObjects(event.snapshotVersion, FSTTestVersion(3));
XCTAssertEqual(event.documentUpdates.count, 2);
- XCTAssertEqualObjects(event.documentUpdates[doc1.key], doc1);
- XCTAssertEqualObjects(event.documentUpdates[doc2.key], doc2);
+ XCTAssertEqualObjects(event.documentUpdates[(FSTDocumentKey *)doc1.key], doc1);
+ XCTAssertEqualObjects(event.documentUpdates[(FSTDocumentKey *)doc2.key], doc2);
XCTAssertEqual(event.targetChanges.count, 6);
@@ -111,8 +111,8 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)testWillIgnoreEventsForPendingTargets {
- FSTDocument *doc1 = FSTTestDoc(@"docs/1", 1, @{ @"value" : @1 }, NO);
- FSTDocument *doc2 = FSTTestDoc(@"docs/2", 2, @{ @"value" : @2 }, NO);
+ FSTDocument *doc1 = FSTTestDoc("docs/1", 1, @{ @"value" : @1 }, NO);
+ FSTDocument *doc2 = FSTTestDoc("docs/2", 2, @{ @"value" : @2 }, NO);
FSTWatchChange *change1 = [[FSTDocumentWatchChange alloc] initWithUpdatedTargetIDs:@[ @1 ]
removedTargetIDs:@[]
@@ -144,13 +144,13 @@ NS_ASSUME_NONNULL_BEGIN
// doc1 is ignored because it was part of an inactive target, but doc2 is in the changes
// because it become active.
XCTAssertEqual(event.documentUpdates.count, 1);
- XCTAssertEqualObjects(event.documentUpdates[doc2.key], doc2);
+ XCTAssertEqualObjects(event.documentUpdates[(FSTDocumentKey *)doc2.key], doc2);
XCTAssertEqual(event.targetChanges.count, 1);
}
- (void)testWillIgnoreEventsForRemovedTargets {
- FSTDocument *doc1 = FSTTestDoc(@"docs/1", 1, @{ @"value" : @1 }, NO);
+ FSTDocument *doc1 = FSTTestDoc("docs/1", 1, @{ @"value" : @1 }, NO);
FSTWatchChange *change1 = [[FSTDocumentWatchChange alloc] initWithUpdatedTargetIDs:@[ @1 ]
removedTargetIDs:@[]
@@ -177,9 +177,9 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)testWillKeepResetMappingEvenWithUpdates {
- FSTDocument *doc1 = FSTTestDoc(@"docs/1", 1, @{ @"value" : @1 }, NO);
- FSTDocument *doc2 = FSTTestDoc(@"docs/2", 2, @{ @"value" : @2 }, NO);
- FSTDocument *doc3 = FSTTestDoc(@"docs/3", 3, @{ @"value" : @3 }, NO);
+ FSTDocument *doc1 = FSTTestDoc("docs/1", 1, @{ @"value" : @1 }, NO);
+ FSTDocument *doc2 = FSTTestDoc("docs/2", 2, @{ @"value" : @2 }, NO);
+ FSTDocument *doc3 = FSTTestDoc("docs/3", 3, @{ @"value" : @3 }, NO);
FSTWatchChange *change1 = [[FSTDocumentWatchChange alloc] initWithUpdatedTargetIDs:@[ @1 ]
removedTargetIDs:@[]
@@ -214,9 +214,9 @@ NS_ASSUME_NONNULL_BEGIN
FSTRemoteEvent *event = [aggregator remoteEvent];
XCTAssertEqualObjects(event.snapshotVersion, FSTTestVersion(3));
XCTAssertEqual(event.documentUpdates.count, 3);
- XCTAssertEqualObjects(event.documentUpdates[doc1.key], doc1);
- XCTAssertEqualObjects(event.documentUpdates[doc2.key], doc2);
- XCTAssertEqualObjects(event.documentUpdates[doc3.key], doc3);
+ XCTAssertEqualObjects(event.documentUpdates[(FSTDocumentKey *)doc1.key], doc1);
+ XCTAssertEqualObjects(event.documentUpdates[(FSTDocumentKey *)doc2.key], doc2);
+ XCTAssertEqualObjects(event.documentUpdates[(FSTDocumentKey *)doc3.key], doc3);
XCTAssertEqual(event.targetChanges.count, 1);
@@ -247,8 +247,8 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)testWillHandleTargetAddAndRemovalInSameBatch {
- FSTDocument *doc1a = FSTTestDoc(@"docs/1", 1, @{ @"value" : @1 }, NO);
- FSTDocument *doc1b = FSTTestDoc(@"docs/1", 1, @{ @"value" : @2 }, NO);
+ FSTDocument *doc1a = FSTTestDoc("docs/1", 1, @{ @"value" : @1 }, NO);
+ FSTDocument *doc1b = FSTTestDoc("docs/1", 1, @{ @"value" : @2 }, NO);
FSTWatchChange *change1 = [[FSTDocumentWatchChange alloc] initWithUpdatedTargetIDs:@[ @1 ]
removedTargetIDs:@[ @2 ]
@@ -266,7 +266,7 @@ NS_ASSUME_NONNULL_BEGIN
FSTRemoteEvent *event = [aggregator remoteEvent];
XCTAssertEqualObjects(event.snapshotVersion, FSTTestVersion(3));
XCTAssertEqual(event.documentUpdates.count, 1);
- XCTAssertEqualObjects(event.documentUpdates[doc1b.key], doc1b);
+ XCTAssertEqualObjects(event.documentUpdates[(FSTDocumentKey *)doc1b.key], doc1b);
XCTAssertEqual(event.targetChanges.count, 2);
@@ -298,8 +298,8 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)testTargetAddedChangeWillResetPreviousState {
- FSTDocument *doc1 = FSTTestDoc(@"docs/1", 1, @{ @"value" : @1 }, NO);
- FSTDocument *doc2 = FSTTestDoc(@"docs/2", 2, @{ @"value" : @2 }, NO);
+ FSTDocument *doc1 = FSTTestDoc("docs/1", 1, @{ @"value" : @1 }, NO);
+ FSTDocument *doc2 = FSTTestDoc("docs/2", 2, @{ @"value" : @2 }, NO);
FSTWatchChange *change1 = [[FSTDocumentWatchChange alloc] initWithUpdatedTargetIDs:@[ @1, @3 ]
removedTargetIDs:@[ @2 ]
@@ -332,8 +332,8 @@ NS_ASSUME_NONNULL_BEGIN
FSTRemoteEvent *event = [aggregator remoteEvent];
XCTAssertEqualObjects(event.snapshotVersion, FSTTestVersion(3));
XCTAssertEqual(event.documentUpdates.count, 2);
- XCTAssertEqualObjects(event.documentUpdates[doc1.key], doc1);
- XCTAssertEqualObjects(event.documentUpdates[doc2.key], doc2);
+ XCTAssertEqualObjects(event.documentUpdates[(FSTDocumentKey *)doc1.key], doc1);
+ XCTAssertEqualObjects(event.documentUpdates[(FSTDocumentKey *)doc2.key], doc2);
// target 1 and 3 are affected (1 because of re-add), target 2 is not because of remove
XCTAssertEqual(event.targetChanges.count, 2);
@@ -394,8 +394,8 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)testExistenceFilterMismatchResetsTarget {
- FSTDocument *doc1 = FSTTestDoc(@"docs/1", 1, @{ @"value" : @1 }, NO);
- FSTDocument *doc2 = FSTTestDoc(@"docs/2", 2, @{ @"value" : @2 }, NO);
+ FSTDocument *doc1 = FSTTestDoc("docs/1", 1, @{ @"value" : @1 }, NO);
+ FSTDocument *doc2 = FSTTestDoc("docs/2", 2, @{ @"value" : @2 }, NO);
FSTWatchChange *change1 = [[FSTDocumentWatchChange alloc] initWithUpdatedTargetIDs:@[ @1 ]
removedTargetIDs:@[]
@@ -419,8 +419,8 @@ NS_ASSUME_NONNULL_BEGIN
FSTRemoteEvent *event = [aggregator remoteEvent];
XCTAssertEqualObjects(event.snapshotVersion, FSTTestVersion(3));
XCTAssertEqual(event.documentUpdates.count, 2);
- XCTAssertEqualObjects(event.documentUpdates[doc1.key], doc1);
- XCTAssertEqualObjects(event.documentUpdates[doc2.key], doc2);
+ XCTAssertEqualObjects(event.documentUpdates[(FSTDocumentKey *)doc1.key], doc1);
+ XCTAssertEqualObjects(event.documentUpdates[(FSTDocumentKey *)doc2.key], doc2);
XCTAssertEqual(event.targetChanges.count, 1);
@@ -443,11 +443,11 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)testDocumentUpdate {
- FSTDocument *doc1 = FSTTestDoc(@"docs/1", 1, @{ @"value" : @1 }, NO);
+ FSTDocument *doc1 = FSTTestDoc("docs/1", 1, @{ @"value" : @1 }, NO);
FSTDeletedDocument *deletedDoc1 =
[FSTDeletedDocument documentWithKey:doc1.key version:FSTTestVersion(3)];
- FSTDocument *doc2 = FSTTestDoc(@"docs/2", 2, @{ @"value" : @2 }, NO);
- FSTDocument *doc3 = FSTTestDoc(@"docs/3", 3, @{ @"value" : @3 }, NO);
+ FSTDocument *doc2 = FSTTestDoc("docs/2", 2, @{ @"value" : @2 }, NO);
+ FSTDocument *doc3 = FSTTestDoc("docs/3", 3, @{ @"value" : @3 }, NO);
FSTWatchChange *change1 = [[FSTDocumentWatchChange alloc] initWithUpdatedTargetIDs:@[ @1 ]
removedTargetIDs:@[]
@@ -466,8 +466,8 @@ NS_ASSUME_NONNULL_BEGIN
FSTRemoteEvent *event = [aggregator remoteEvent];
XCTAssertEqualObjects(event.snapshotVersion, FSTTestVersion(3));
XCTAssertEqual(event.documentUpdates.count, 2);
- XCTAssertEqualObjects(event.documentUpdates[doc1.key], doc1);
- XCTAssertEqualObjects(event.documentUpdates[doc2.key], doc2);
+ XCTAssertEqualObjects(event.documentUpdates[(FSTDocumentKey *)doc1.key], doc1);
+ XCTAssertEqualObjects(event.documentUpdates[(FSTDocumentKey *)doc2.key], doc2);
// Update doc1
[event addDocumentUpdate:deletedDoc1];
@@ -476,11 +476,11 @@ NS_ASSUME_NONNULL_BEGIN
XCTAssertEqualObjects(event.snapshotVersion, FSTTestVersion(3));
XCTAssertEqual(event.documentUpdates.count, 3);
// doc1 is replaced
- XCTAssertEqualObjects(event.documentUpdates[doc1.key], deletedDoc1);
+ XCTAssertEqualObjects(event.documentUpdates[(FSTDocumentKey *)doc1.key], deletedDoc1);
// doc2 is untouched
- XCTAssertEqualObjects(event.documentUpdates[doc2.key], doc2);
+ XCTAssertEqualObjects(event.documentUpdates[(FSTDocumentKey *)doc2.key], doc2);
// doc3 is new
- XCTAssertEqualObjects(event.documentUpdates[doc3.key], doc3);
+ XCTAssertEqualObjects(event.documentUpdates[(FSTDocumentKey *)doc3.key], doc3);
// Target is unchanged
XCTAssertEqual(event.targetChanges.count, 1);
diff --git a/Firestore/Example/Tests/Remote/FSTSerializerBetaTests.mm b/Firestore/Example/Tests/Remote/FSTSerializerBetaTests.mm
index 4c3682f..64f4777 100644
--- a/Firestore/Example/Tests/Remote/FSTSerializerBetaTests.mm
+++ b/Firestore/Example/Tests/Remote/FSTSerializerBetaTests.mm
@@ -741,7 +741,7 @@ NS_ASSUME_NONNULL_BEGIN
initWithUpdatedTargetIDs:@[ @1, @2 ]
removedTargetIDs:@[]
documentKey:FSTTestDocKey(@"coll/1")
- document:FSTTestDoc(@"coll/1", 5, @{@"foo" : @"bar"}, NO)];
+ document:FSTTestDoc("coll/1", 5, @{@"foo" : @"bar"}, NO)];
GCFSListenResponse *listenResponse = [GCFSListenResponse message];
listenResponse.documentChange.document.name = @"projects/p/databases/d/documents/coll/1";
listenResponse.documentChange.document.updateTime.nanos = 5000;
@@ -760,7 +760,7 @@ NS_ASSUME_NONNULL_BEGIN
initWithUpdatedTargetIDs:@[ @2 ]
removedTargetIDs:@[ @1 ]
documentKey:FSTTestDocKey(@"coll/1")
- document:FSTTestDoc(@"coll/1", 5, @{@"foo" : @"bar"}, NO)];
+ document:FSTTestDoc("coll/1", 5, @{@"foo" : @"bar"}, NO)];
GCFSListenResponse *listenResponse = [GCFSListenResponse message];
listenResponse.documentChange.document.name = @"projects/p/databases/d/documents/coll/1";
listenResponse.documentChange.document.updateTime.nanos = 5000;
@@ -779,7 +779,7 @@ NS_ASSUME_NONNULL_BEGIN
[[FSTDocumentWatchChange alloc] initWithUpdatedTargetIDs:@[]
removedTargetIDs:@[ @1, @2 ]
documentKey:FSTTestDocKey(@"coll/1")
- document:FSTTestDeletedDoc(@"coll/1", 5)];
+ document:FSTTestDeletedDoc("coll/1", 5)];
GCFSListenResponse *listenResponse = [GCFSListenResponse message];
listenResponse.documentDelete.document = @"projects/p/databases/d/documents/coll/1";
listenResponse.documentDelete.readTime.nanos = 5000;
diff --git a/Firestore/Example/Tests/Remote/FSTWatchChangeTests.mm b/Firestore/Example/Tests/Remote/FSTWatchChangeTests.mm
index df2496b..d707e3c 100644
--- a/Firestore/Example/Tests/Remote/FSTWatchChangeTests.mm
+++ b/Firestore/Example/Tests/Remote/FSTWatchChangeTests.mm
@@ -32,7 +32,7 @@ NS_ASSUME_NONNULL_BEGIN
@implementation FSTWatchChangeTests
- (void)testDocumentChange {
- FSTMaybeDocument *doc = FSTTestDoc(@"a/b", 1, @{}, NO);
+ FSTMaybeDocument *doc = FSTTestDoc("a/b", 1, @{}, NO);
FSTDocumentWatchChange *change =
[[FSTDocumentWatchChange alloc] initWithUpdatedTargetIDs:@[ @1, @2, @3 ]
removedTargetIDs:@[ @4, @5 ]
diff --git a/Firestore/Example/Tests/SpecTests/FSTSpecTests.mm b/Firestore/Example/Tests/SpecTests/FSTSpecTests.mm
index 0f57b81..10aa6c2 100644
--- a/Firestore/Example/Tests/SpecTests/FSTSpecTests.mm
+++ b/Firestore/Example/Tests/SpecTests/FSTSpecTests.mm
@@ -153,7 +153,9 @@ static NSString *const kNoIOSTag = @"no-ios";
}
}
NSNumber *version = change[1];
- FSTDocument *doc = FSTTestDoc(change[0], version.longLongValue, change[2], hasMutations);
+ XCTAssert([change[0] isKindOfClass:[NSString class]]);
+ FSTDocument *doc = FSTTestDoc(util::MakeStringView((NSString *)change[0]), version.longLongValue,
+ change[2], hasMutations);
return [FSTDocumentViewChange changeWithDocument:doc type:type];
}
diff --git a/Firestore/Example/Tests/Util/FSTHelpers.h b/Firestore/Example/Tests/Util/FSTHelpers.h
index d86201b..d05c1f1 100644
--- a/Firestore/Example/Tests/Util/FSTHelpers.h
+++ b/Firestore/Example/Tests/Util/FSTHelpers.h
@@ -192,13 +192,13 @@ typedef int64_t FSTTestSnapshotVersion;
FSTSnapshotVersion *FSTTestVersion(FSTTestSnapshotVersion version);
/** A convenience method for creating docs for tests. */
-FSTDocument *FSTTestDoc(NSString *path,
+FSTDocument *FSTTestDoc(const absl::string_view path,
FSTTestSnapshotVersion version,
NSDictionary<NSString *, id> *data,
BOOL hasMutations);
/** A convenience method for creating deleted docs for tests. */
-FSTDeletedDocument *FSTTestDeletedDoc(NSString *path, FSTTestSnapshotVersion version);
+FSTDeletedDocument *FSTTestDeletedDoc(const absl::string_view path, FSTTestSnapshotVersion version);
/**
* A convenience method for creating a document reference from a path string.
diff --git a/Firestore/Example/Tests/Util/FSTHelpers.mm b/Firestore/Example/Tests/Util/FSTHelpers.mm
index be02002..5751739 100644
--- a/Firestore/Example/Tests/Util/FSTHelpers.mm
+++ b/Firestore/Example/Tests/Util/FSTHelpers.mm
@@ -43,6 +43,7 @@
#import "Firestore/Source/Util/FSTAssert.h"
#include "Firestore/core/src/firebase/firestore/model/database_id.h"
+#include "Firestore/core/src/firebase/firestore/model/document_key.h"
#include "Firestore/core/src/firebase/firestore/model/field_value.h"
#include "Firestore/core/src/firebase/firestore/model/resource_path.h"
#include "Firestore/core/src/firebase/firestore/util/string_apple.h"
@@ -51,6 +52,7 @@
namespace util = firebase::firestore::util;
namespace testutil = firebase::firestore::testutil;
using firebase::firestore::model::DatabaseId;
+using firebase::firestore::model::DocumentKey;
using firebase::firestore::model::FieldPath;
using firebase::firestore::model::FieldValue;
using firebase::firestore::model::ResourcePath;
@@ -148,19 +150,20 @@ FSTSnapshotVersion *FSTTestVersion(FSTTestSnapshotVersion versionMicroseconds) {
return [FSTSnapshotVersion versionWithTimestamp:timestamp];
}
-FSTDocument *FSTTestDoc(NSString *path,
+FSTDocument *FSTTestDoc(const absl::string_view path,
FSTTestSnapshotVersion version,
NSDictionary<NSString *, id> *data,
BOOL hasMutations) {
- FSTDocumentKey *key = FSTTestDocKey(path);
+ DocumentKey key = testutil::Key(path);
return [FSTDocument documentWithData:FSTTestObjectValue(data)
key:key
version:FSTTestVersion(version)
hasLocalMutations:hasMutations];
}
-FSTDeletedDocument *FSTTestDeletedDoc(NSString *path, FSTTestSnapshotVersion version) {
- FSTDocumentKey *key = FSTTestDocKey(path);
+FSTDeletedDocument *FSTTestDeletedDoc(const absl::string_view path,
+ FSTTestSnapshotVersion version) {
+ DocumentKey key = testutil::Key(path);
return [FSTDeletedDocument documentWithKey:key version:FSTTestVersion(version)];
}