aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Example/Tests/Local/FSTRemoteDocumentCacheTests.mm
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/FSTRemoteDocumentCacheTests.mm
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/FSTRemoteDocumentCacheTests.mm')
-rw-r--r--Firestore/Example/Tests/Local/FSTRemoteDocumentCacheTests.mm33
1 files changed, 20 insertions, 13 deletions
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];
}