@@ -81,6 +81,37 @@ - (void)testSetAndReadADocument {
81
81
[self setAndReadADocumentAtPath: kDocPath ];
82
82
}
83
83
84
+ - (void )testSetAndReadSeveralDocuments {
85
+ if (!self.remoteDocumentCache ) return ;
86
+
87
+ self.persistence .run (" testSetAndReadSeveralDocuments" , [=]() {
88
+ NSArray <FSTDocument *> *written =
89
+ @[ [self setTestDocumentAtPath: kDocPath ], [self setTestDocumentAtPath: kLongDocPath ] ];
90
+ MaybeDocumentMap read = [self .remoteDocumentCache
91
+ entriesForKeys: DocumentKeySet{testutil::Key (kDocPath ), testutil::Key (kLongDocPath )}];
92
+ [self expectMap: read hasDocsInArray: written exactly: YES ];
93
+ });
94
+ }
95
+
96
+ - (void )testSetAndReadSeveralDocumentsIncludingMissingDocument {
97
+ if (!self.remoteDocumentCache ) return ;
98
+
99
+ self.persistence .run (" testSetAndReadSeveralDocumentsIncludingMissingDocument" , [=]() {
100
+ NSArray <FSTDocument *> *written =
101
+ @[ [self setTestDocumentAtPath: kDocPath ], [self setTestDocumentAtPath: kLongDocPath ] ];
102
+ MaybeDocumentMap read =
103
+ [self .remoteDocumentCache entriesForKeys: DocumentKeySet{
104
+ testutil::Key (kDocPath ),
105
+ testutil::Key (kLongDocPath ),
106
+ testutil::Key (" foo/nonexistent" ),
107
+ }];
108
+ [self expectMap: read hasDocsInArray: written exactly: NO ];
109
+ auto found = read.find (DocumentKey::FromPathString (" foo/nonexistent" ));
110
+ XCTAssertTrue (found != read.end ());
111
+ XCTAssertNil (found->second );
112
+ });
113
+ }
114
+
84
115
- (void )testSetAndReadADocumentAtDeepPath {
85
116
if (!self.remoteDocumentCache ) return ;
86
117
@@ -144,7 +175,7 @@ - (void)testDocumentsMatchingQuery {
144
175
145
176
FSTQuery *query = FSTTestQuery (" b" );
146
177
DocumentMap results = [self .remoteDocumentCache documentsMatchingQuery: query];
147
- [self expectMap: results
178
+ [self expectMap: results. underlying_map ()
148
179
hasDocsInArray: @[
149
180
FSTTestDoc (" b/1" , kVersion , _kDocData, FSTDocumentStateSynced),
150
181
FSTTestDoc (" b/2" , kVersion , _kDocData, FSTDocumentStateSynced)
@@ -162,16 +193,16 @@ - (FSTDocument *)setTestDocumentAtPath:(const absl::string_view)path {
162
193
return doc;
163
194
}
164
195
165
- - (void )expectMap : (const DocumentMap &)map
196
+ - (void )expectMap : (const MaybeDocumentMap &)map
166
197
hasDocsInArray : (NSArray <FSTDocument *> *)expected
167
198
exactly : (BOOL )exactly {
168
199
if (exactly) {
169
200
XCTAssertEqual (map.size (), [expected count ]);
170
201
}
171
202
for (FSTDocument *doc in expected) {
172
203
FSTDocument *actual = nil ;
173
- auto found = map.underlying_map (). find (doc.key );
174
- if (found != map.underlying_map (). end ()) {
204
+ auto found = map.find (doc.key );
205
+ if (found != map.end ()) {
175
206
actual = static_cast <FSTDocument *>(found->second );
176
207
}
177
208
XCTAssertEqualObjects (actual, doc);
0 commit comments