aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Example/Tests/Local
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/Local
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/Local')
-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
4 files changed, 152 insertions, 145 deletions
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);