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
9292 src/sanity_test.cc
9393 src/server_timestamp_test.cc
9494 src/smoke_test.cc
95+ src/source_test.cc
9596 src/transaction_test.cc
9697 src/type_test.cc
9798 src/validation_test.cc
Original file line number Diff line number Diff line change @@ -195,6 +195,13 @@ DocumentReference FirestoreIntegrationTest::Document() const {
195195 return TestFirestore ()->Document (DocumentPath ());
196196}
197197
198+ DocumentReference FirestoreIntegrationTest::DocumentWithData (
199+ const MapFieldValue& data) const {
200+ DocumentReference docRef = Document ();
201+ WriteDocument (docRef, data);
202+ return docRef;
203+ }
204+
198205void FirestoreIntegrationTest::WriteDocument (DocumentReference reference,
199206 const MapFieldValue& data) const {
200207 Future<void > future = reference.Set (data);
@@ -257,6 +264,16 @@ std::vector<MapFieldValue> FirestoreIntegrationTest::QuerySnapshotToValues(
257264 return result;
258265}
259266
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+
260277/* static */
261278void FirestoreIntegrationTest::Await (const Future<void >& future) {
262279 while (future.status () == FutureStatus::kFutureStatusPending ) {
Original file line number Diff line number Diff line change @@ -228,6 +228,10 @@ class FirestoreIntegrationTest : public testing::Test {
228228 // Return a reference to the document with auto-generated id.
229229 DocumentReference Document () const ;
230230
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+
231235 // Write to the specified document and wait for the write to complete.
232236 void WriteDocument (DocumentReference reference,
233237 const MapFieldValue& data) const ;
@@ -262,6 +266,10 @@ class FirestoreIntegrationTest : public testing::Test {
262266 std::vector<MapFieldValue> QuerySnapshotToValues (
263267 const QuerySnapshot& snapshot) const ;
264268
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+
265273 // TODO(zxu): add a helper function to block on signal.
266274
267275 // A helper function to block until the future completes.
You can’t perform that action at this time.
0 commit comments