File tree Expand file tree Collapse file tree 4 files changed +552
-0
lines changed
firestore/integration_test_internal Expand file tree Collapse file tree 4 files changed +552
-0
lines changed Original file line number Diff line number Diff line change @@ -92,6 +92,7 @@ set(FIREBASE_INTEGRATION_TEST_PORTABLE_TEST_SRCS
92
92
src/sanity_test.cc
93
93
src/server_timestamp_test.cc
94
94
src/smoke_test.cc
95
+ src/source_test.cc
95
96
src/transaction_test.cc
96
97
src/type_test.cc
97
98
src/validation_test.cc
Original file line number Diff line number Diff line change @@ -195,6 +195,13 @@ DocumentReference FirestoreIntegrationTest::Document() const {
195
195
return TestFirestore ()->Document (DocumentPath ());
196
196
}
197
197
198
+ DocumentReference FirestoreIntegrationTest::DocumentWithData (
199
+ const MapFieldValue& data) const {
200
+ DocumentReference docRef = Document ();
201
+ WriteDocument (docRef, data);
202
+ return docRef;
203
+ }
204
+
198
205
void FirestoreIntegrationTest::WriteDocument (DocumentReference reference,
199
206
const MapFieldValue& data) const {
200
207
Future<void > future = reference.Set (data);
@@ -257,6 +264,16 @@ std::vector<MapFieldValue> FirestoreIntegrationTest::QuerySnapshotToValues(
257
264
return result;
258
265
}
259
266
267
+ std::map<std::string, MapFieldValue>
268
+ FirestoreIntegrationTest::QuerySnapshotToMap (
269
+ const QuerySnapshot& snapshot) const {
270
+ std::map<std::string, MapFieldValue> result;
271
+ for (const DocumentSnapshot& doc : snapshot.documents ()) {
272
+ result[doc.id ()] = doc.GetData ();
273
+ }
274
+ return result;
275
+ }
276
+
260
277
/* static */
261
278
void FirestoreIntegrationTest::Await (const Future<void >& future) {
262
279
while (future.status () == FutureStatus::kFutureStatusPending ) {
Original file line number Diff line number Diff line change @@ -228,6 +228,10 @@ class FirestoreIntegrationTest : public testing::Test {
228
228
// Return a reference to the document with auto-generated id.
229
229
DocumentReference Document () const ;
230
230
231
+ // Returns a reference to a document with auto-generated id. Writes the given
232
+ // data to the document and waits for the write to complete.
233
+ DocumentReference DocumentWithData (const MapFieldValue& data) const ;
234
+
231
235
// Write to the specified document and wait for the write to complete.
232
236
void WriteDocument (DocumentReference reference,
233
237
const MapFieldValue& data) const ;
@@ -262,6 +266,10 @@ class FirestoreIntegrationTest : public testing::Test {
262
266
std::vector<MapFieldValue> QuerySnapshotToValues (
263
267
const QuerySnapshot& snapshot) const ;
264
268
269
+ // Convert a QuerySnapshot to a map from document id to document content.
270
+ std::map<std::string, MapFieldValue> QuerySnapshotToMap (
271
+ const QuerySnapshot& snapshot) const ;
272
+
265
273
// TODO(zxu): add a helper function to block on signal.
266
274
267
275
// A helper function to block until the future completes.
You can’t perform that action at this time.
0 commit comments