@@ -121,6 +121,7 @@ TEST_F(FirestoreIntegrationTest, TestCanUpdateAnExistingDocument) {
121
121
MapFieldValue{{" desc" , FieldValue::String (" NewDescription" )},
122
122
{
" owner.email" ,
FieldValue::String (
" [email protected] " )}}));
123
123
DocumentSnapshot doc = ReadDocument (document);
124
+ EXPECT_TRUE (doc.exists ());
124
125
EXPECT_THAT (
125
126
doc.GetData (),
126
127
ContainerEq (MapFieldValue{
@@ -151,11 +152,13 @@ TEST_F(FirestoreIntegrationTest, TestCanUpdateAnUnknownDocument) {
151
152
EXPECT_EQ (Error::kErrorUnavailable , future.error ());
152
153
153
154
writer_snapshot = ReadDocument (writer_reference);
155
+ EXPECT_TRUE (writer_snapshot.exists ());
154
156
EXPECT_THAT (writer_snapshot.GetData (),
155
157
ContainerEq (MapFieldValue{{" a" , FieldValue::String (" a" )},
156
158
{" b" , FieldValue::String (" b" )}}));
157
159
EXPECT_FALSE (writer_snapshot.metadata ().is_from_cache ());
158
160
DocumentSnapshot reader_snapshot = ReadDocument (reader_reference);
161
+ EXPECT_TRUE (reader_snapshot.exists ());
159
162
EXPECT_THAT (reader_snapshot.GetData (),
160
163
ContainerEq (MapFieldValue{{" a" , FieldValue::String (" a" )},
161
164
{" b" , FieldValue::String (" b" )}}));
@@ -174,6 +177,7 @@ TEST_F(FirestoreIntegrationTest, TestCanOverwriteAnExistingDocumentUsingSet) {
174
177
{" owner.data" ,
175
178
FieldValue::Map ({{" name" , FieldValue::String (" Sebastian" )}})}}));
176
179
DocumentSnapshot snapshot = ReadDocument (document);
180
+ EXPECT_TRUE (snapshot.exists ());
177
181
EXPECT_THAT (
178
182
snapshot.GetData (),
179
183
ContainerEq (MapFieldValue{
@@ -197,6 +201,7 @@ TEST_F(FirestoreIntegrationTest,
197
201
FieldValue::Map ({{" name" , FieldValue::String (" Sebastian" )}})}},
198
202
SetOptions::Merge ()));
199
203
DocumentSnapshot snapshot = ReadDocument (document);
204
+ EXPECT_TRUE (snapshot.exists ());
200
205
EXPECT_THAT (
201
206
snapshot.GetData (),
202
207
ContainerEq (MapFieldValue{
@@ -230,22 +235,27 @@ TEST_F(FirestoreIntegrationTest, TestCanMergeEmptyObject) {
230
235
231
236
document.Set (MapFieldValue{});
232
237
DocumentSnapshot snapshot = accumulator.Await ();
238
+ EXPECT_TRUE (snapshot.exists ());
233
239
EXPECT_THAT (snapshot.GetData (), ContainerEq (MapFieldValue{}));
234
240
235
241
Await (document.Set (MapFieldValue{{" a" , FieldValue::Map ({})}},
236
242
SetOptions::MergeFields ({" a" })));
237
243
snapshot = accumulator.Await ();
244
+ EXPECT_TRUE (snapshot.exists ());
238
245
EXPECT_THAT (snapshot.GetData (),
239
246
ContainerEq (MapFieldValue{{" a" , FieldValue::Map ({})}}));
240
247
241
248
Await (document.Set (MapFieldValue{{" b" , FieldValue::Map ({})}},
242
249
SetOptions::Merge ()));
243
250
snapshot = accumulator.Await ();
251
+ EXPECT_TRUE (snapshot.exists ());
244
252
EXPECT_THAT (snapshot.GetData (),
245
253
ContainerEq (MapFieldValue{{" a" , FieldValue::Map ({})},
246
254
{" b" , FieldValue::Map ({})}}));
247
255
248
- snapshot = *Await (document.Get (Source::kServer ));
256
+ auto * snapshot_ptr = Await (document.Get (Source::kServer ));
257
+ ASSERT_TRUE (snapshot_ptr);
258
+ snapshot = *snapshot_ptr;
249
259
EXPECT_THAT (snapshot.GetData (),
250
260
ContainerEq (MapFieldValue{{" a" , FieldValue::Map ({})},
251
261
{" b" , FieldValue::Map ({})}}));
@@ -294,6 +304,7 @@ TEST_F(FirestoreIntegrationTest, TestCanDeleteFieldUsingMergeFields) {
294
304
{" foo" , FieldValue::Delete ()}})}},
295
305
SetOptions::MergeFields ({" foo" , " inner" , " nested.foo" })));
296
306
DocumentSnapshot snapshot = ReadDocument (document);
307
+ EXPECT_TRUE (snapshot.exists ());
297
308
EXPECT_THAT (
298
309
snapshot.GetData (),
299
310
ContainerEq (MapFieldValue{
@@ -341,6 +352,7 @@ TEST_F(FirestoreIntegrationTest, TestMergeReplacesArrays) {
341
352
{{" data" , FieldValue::String (" new" )}})})}},
342
353
SetOptions::Merge ()));
343
354
DocumentSnapshot snapshot = ReadDocument (document);
355
+ EXPECT_TRUE (snapshot.exists ());
344
356
EXPECT_THAT (
345
357
snapshot.GetData (),
346
358
ContainerEq (MapFieldValue{
@@ -366,6 +378,7 @@ TEST_F(FirestoreIntegrationTest,
366
378
{
" email" ,
FieldValue::String (
" [email protected] " )}})}},
367
379
SetOptions::MergeFieldPaths ({{" desc" }, {" owner.data" , " name" }})));
368
380
DocumentSnapshot snapshot = ReadDocument (document);
381
+ EXPECT_TRUE (snapshot.exists ());
369
382
EXPECT_THAT (
370
383
snapshot.GetData (),
371
384
ContainerEq (MapFieldValue{
@@ -405,6 +418,7 @@ TEST_F(FirestoreIntegrationTest, TestFieldsNotInFieldMaskAreIgnored) {
405
418
{" owner" , FieldValue::String (" Sebastian" )}},
406
419
SetOptions::MergeFields ({" desc" })));
407
420
DocumentSnapshot snapshot = ReadDocument (document);
421
+ EXPECT_TRUE (snapshot.exists ());
408
422
EXPECT_THAT (
409
423
snapshot.GetData (),
410
424
ContainerEq (MapFieldValue{
@@ -426,6 +440,7 @@ TEST_F(FirestoreIntegrationTest, TestFieldDeletesNotInFieldMaskAreIgnored) {
426
440
{" owner" , FieldValue::Delete ()}},
427
441
SetOptions::MergeFields ({" desc" })));
428
442
DocumentSnapshot snapshot = ReadDocument (document);
443
+ EXPECT_TRUE (snapshot.exists ());
429
444
EXPECT_THAT (
430
445
snapshot.GetData (),
431
446
ContainerEq (MapFieldValue{
@@ -447,6 +462,7 @@ TEST_F(FirestoreIntegrationTest, TestFieldTransformsNotInFieldMaskAreIgnored) {
447
462
{" owner" , FieldValue::ServerTimestamp ()}},
448
463
SetOptions::MergeFields ({" desc" })));
449
464
DocumentSnapshot snapshot = ReadDocument (document);
465
+ EXPECT_TRUE (snapshot.exists ());
450
466
EXPECT_THAT (
451
467
snapshot.GetData (),
452
468
ContainerEq (MapFieldValue{
@@ -467,6 +483,7 @@ TEST_F(FirestoreIntegrationTest, TestCanSetEmptyFieldMask) {
467
483
MapFieldValue{{" desc" , FieldValue::String (" NewDescription" )}},
468
484
SetOptions::MergeFields ({})));
469
485
DocumentSnapshot snapshot = ReadDocument (document);
486
+ EXPECT_TRUE (snapshot.exists ());
470
487
EXPECT_THAT (
471
488
snapshot.GetData (),
472
489
ContainerEq (MapFieldValue{
@@ -491,6 +508,7 @@ TEST_F(FirestoreIntegrationTest, TestCanSpecifyFieldsMultipleTimesInFieldMask) {
491
508
{
" email" ,
FieldValue::String (
" [email protected] " )}})}},
492
509
SetOptions::MergeFields ({" owner.name" , " owner" , " owner" })));
493
510
DocumentSnapshot snapshot = ReadDocument (document);
511
+ EXPECT_TRUE (snapshot.exists ());
494
512
EXPECT_THAT (
495
513
snapshot.GetData (),
496
514
ContainerEq (MapFieldValue{
@@ -509,6 +527,7 @@ TEST_F(FirestoreIntegrationTest, TestCanDeleteAFieldWithAnUpdate) {
509
527
{
" email" ,
FieldValue::String (
" [email protected] " )}})}}));
510
528
Await (document.Update (MapFieldValue{{" owner.email" , FieldValue::Delete ()}}));
511
529
DocumentSnapshot snapshot = ReadDocument (document);
530
+ EXPECT_TRUE (snapshot.exists ());
512
531
EXPECT_THAT (snapshot.GetData (),
513
532
ContainerEq (MapFieldValue{
514
533
{" desc" , FieldValue::String (" Description" )},
@@ -524,6 +543,7 @@ TEST_F(FirestoreIntegrationTest, TestCanUpdateFieldsWithDots) {
524
543
Await (document.Update ({{FieldPath{" a.b" }, FieldValue::String (" new" )}}));
525
544
Await (document.Update ({{FieldPath{" c.d" }, FieldValue::String (" new" )}}));
526
545
DocumentSnapshot snapshot = ReadDocument (document);
546
+ EXPECT_TRUE (snapshot.exists ());
527
547
EXPECT_THAT (snapshot.GetData (),
528
548
ContainerEq (MapFieldValue{{" a.b" , FieldValue::String (" new" )},
529
549
{" c.d" , FieldValue::String (" new" )},
@@ -539,6 +559,7 @@ TEST_F(FirestoreIntegrationTest, TestCanUpdateNestedFields) {
539
559
Await (document.Update ({{" a.b" , FieldValue::String (" new" )}}));
540
560
Await (document.Update ({{" c.d" , FieldValue::String (" new" )}}));
541
561
DocumentSnapshot snapshot = ReadDocument (document);
562
+ EXPECT_TRUE (snapshot.exists ());
542
563
EXPECT_THAT (snapshot.GetData (),
543
564
ContainerEq (MapFieldValue{
544
565
{" a" , FieldValue::Map ({{" b" , FieldValue::String (" new" )}})},
@@ -559,6 +580,7 @@ TEST_F(FirestoreIntegrationTest, TestCanUpdateFieldsWithMultipleDeletes) {
559
580
{FieldPath{" key3" }, FieldValue::Delete ()},
560
581
{FieldPath{" key5" }, FieldValue::Delete ()}}));
561
582
DocumentSnapshot snapshot = ReadDocument (document);
583
+ EXPECT_TRUE (snapshot.exists ());
562
584
EXPECT_THAT (snapshot.GetData (), ContainerEq (MapFieldValue{
563
585
{" key2" , FieldValue::String (" value2" )},
564
586
{" key4" , FieldValue::String (" value4" )}}));
@@ -568,6 +590,7 @@ TEST_F(FirestoreIntegrationTest, TestDeleteDocument) {
568
590
DocumentReference document = Collection (" rooms" ).Document (" eros" );
569
591
WriteDocument (document, MapFieldValue{{" value" , FieldValue::String (" bar" )}});
570
592
DocumentSnapshot snapshot = ReadDocument (document);
593
+ EXPECT_TRUE (snapshot.exists ());
571
594
EXPECT_THAT (snapshot.GetData (),
572
595
ContainerEq (MapFieldValue{{" value" , FieldValue::String (" bar" )}}));
573
596
@@ -605,6 +628,7 @@ TEST_F(FirestoreIntegrationTest,
605
628
DocumentReference document = Collection (" rooms" ).Document ();
606
629
Await (document.Set (MapFieldValue{{" foo" , FieldValue::Double (1.0 )}}));
607
630
DocumentSnapshot snapshot = ReadDocument (document);
631
+ EXPECT_TRUE (snapshot.exists ());
608
632
EXPECT_THAT (snapshot.GetData (),
609
633
ContainerEq (MapFieldValue{{" foo" , FieldValue::Double (1.0 )}}));
610
634
}
@@ -773,7 +797,9 @@ TEST_F(FirestoreIntegrationTest, TestListenCanBeCalledMultipleTimes) {
773
797
});
774
798
});
775
799
776
- EXPECT_THAT (test_data.WaitForDocumentSnapshot ().GetData (),
800
+ DocumentSnapshot snapshot1 = test_data.WaitForDocumentSnapshot ();
801
+ EXPECT_TRUE (snapshot1.exists ());
802
+ EXPECT_THAT (snapshot1.GetData (),
777
803
ContainerEq (MapFieldValue{{" foo" , FieldValue::String (" bar" )}}));
778
804
}
779
805
@@ -800,10 +826,12 @@ TEST_F(FirestoreIntegrationTest, TestDocumentSnapshotEventsForAdd) {
800
826
WriteDocument (document, MapFieldValue{{" a" , FieldValue::Double (1.0 )}});
801
827
Await (listener, 3 );
802
828
DocumentSnapshot snapshot = listener.last_result (1 );
829
+ EXPECT_TRUE (snapshot.exists ());
803
830
EXPECT_THAT (snapshot.GetData (),
804
831
ContainerEq (MapFieldValue{{" a" , FieldValue::Double (1.0 )}}));
805
832
EXPECT_TRUE (snapshot.metadata ().has_pending_writes ());
806
833
snapshot = listener.last_result ();
834
+ EXPECT_TRUE (snapshot.exists ());
807
835
EXPECT_THAT (snapshot.GetData (),
808
836
ContainerEq (MapFieldValue{{" a" , FieldValue::Double (1.0 )}}));
809
837
EXPECT_FALSE (snapshot.metadata ().has_pending_writes ());
@@ -821,6 +849,7 @@ TEST_F(FirestoreIntegrationTest, TestDocumentSnapshotEventsForChange) {
821
849
listener.AttachTo (&document, MetadataChanges::kInclude );
822
850
Await (listener);
823
851
DocumentSnapshot snapshot = listener.last_result ();
852
+ EXPECT_TRUE (snapshot.exists ());
824
853
EXPECT_THAT (snapshot.GetData (),
825
854
ContainerEq (MapFieldValue{{" a" , FieldValue::Double (1.0 )}}));
826
855
EXPECT_FALSE (snapshot.metadata ().has_pending_writes ());
@@ -829,11 +858,13 @@ TEST_F(FirestoreIntegrationTest, TestDocumentSnapshotEventsForChange) {
829
858
UpdateDocument (document, MapFieldValue{{" a" , FieldValue::Double (2.0 )}});
830
859
Await (listener, 3 );
831
860
snapshot = listener.last_result (1 );
861
+ EXPECT_TRUE (snapshot.exists ());
832
862
EXPECT_THAT (snapshot.GetData (),
833
863
ContainerEq (MapFieldValue{{" a" , FieldValue::Double (2.0 )}}));
834
864
EXPECT_TRUE (snapshot.metadata ().has_pending_writes ());
835
865
EXPECT_FALSE (snapshot.metadata ().is_from_cache ());
836
866
snapshot = listener.last_result ();
867
+ EXPECT_TRUE (snapshot.exists ());
837
868
EXPECT_THAT (snapshot.GetData (),
838
869
ContainerEq (MapFieldValue{{" a" , FieldValue::Double (2.0 )}}));
839
870
EXPECT_FALSE (snapshot.metadata ().has_pending_writes ());
@@ -891,12 +922,14 @@ TEST_F(FirestoreIntegrationTest, TestQuerySnapshotEventsForAdd) {
891
922
WriteDocument (document, MapFieldValue{{" a" , FieldValue::Double (1.0 )}});
892
923
Await (listener, 3 );
893
924
QuerySnapshot snapshot = listener.last_result (1 );
894
- EXPECT_EQ (1 , snapshot.size ());
925
+ ASSERT_EQ (1 , snapshot.size ());
926
+ EXPECT_TRUE (snapshot.documents ()[0 ].exists ());
895
927
EXPECT_THAT (snapshot.documents ()[0 ].GetData (),
896
928
ContainerEq (MapFieldValue{{" a" , FieldValue::Double (1.0 )}}));
897
929
EXPECT_TRUE (snapshot.metadata ().has_pending_writes ());
898
930
snapshot = listener.last_result ();
899
- EXPECT_EQ (1 , snapshot.size ());
931
+ ASSERT_EQ (1 , snapshot.size ());
932
+ EXPECT_TRUE (snapshot.documents ()[0 ].exists ());
900
933
EXPECT_THAT (snapshot.documents ()[0 ].GetData (),
901
934
ContainerEq (MapFieldValue{{" a" , FieldValue::Double (1.0 )}}));
902
935
EXPECT_FALSE (snapshot.metadata ().has_pending_writes ());
@@ -914,20 +947,23 @@ TEST_F(FirestoreIntegrationTest, TestQuerySnapshotEventsForChange) {
914
947
listener.AttachTo (&collection, MetadataChanges::kInclude );
915
948
Await (listener);
916
949
QuerySnapshot snapshot = listener.last_result ();
917
- EXPECT_EQ (1 , snapshot.size ());
950
+ ASSERT_EQ (1 , snapshot.size ());
951
+ EXPECT_TRUE (snapshot.documents ()[0 ].exists ());
918
952
EXPECT_THAT (snapshot.documents ()[0 ].GetData (),
919
953
ContainerEq (MapFieldValue{{" a" , FieldValue::Double (1.0 )}}));
920
954
EXPECT_FALSE (snapshot.metadata ().has_pending_writes ());
921
955
922
956
WriteDocument (document, MapFieldValue{{" a" , FieldValue::Double (2.0 )}});
923
957
Await (listener, 3 );
924
958
snapshot = listener.last_result (1 );
925
- EXPECT_EQ (1 , snapshot.size ());
959
+ ASSERT_EQ (1 , snapshot.size ());
960
+ EXPECT_TRUE (snapshot.documents ()[0 ].exists ());
926
961
EXPECT_THAT (snapshot.documents ()[0 ].GetData (),
927
962
ContainerEq (MapFieldValue{{" a" , FieldValue::Double (2.0 )}}));
928
963
EXPECT_TRUE (snapshot.metadata ().has_pending_writes ());
929
964
snapshot = listener.last_result ();
930
- EXPECT_EQ (1 , snapshot.size ());
965
+ ASSERT_EQ (1 , snapshot.size ());
966
+ EXPECT_TRUE (snapshot.documents ()[0 ].exists ());
931
967
EXPECT_THAT (snapshot.documents ()[0 ].GetData (),
932
968
ContainerEq (MapFieldValue{{" a" , FieldValue::Double (2.0 )}}));
933
969
EXPECT_FALSE (snapshot.metadata ().has_pending_writes ());
@@ -945,7 +981,8 @@ TEST_F(FirestoreIntegrationTest, TestQuerySnapshotEventsForDelete) {
945
981
listener.AttachTo (&collection, MetadataChanges::kInclude );
946
982
Await (listener);
947
983
QuerySnapshot snapshot = listener.last_result ();
948
- EXPECT_EQ (1 , snapshot.size ());
984
+ ASSERT_EQ (1 , snapshot.size ());
985
+ EXPECT_TRUE (snapshot.documents ()[0 ].exists ());
949
986
EXPECT_THAT (snapshot.documents ()[0 ].GetData (),
950
987
ContainerEq (MapFieldValue{{" a" , FieldValue::Double (1.0 )}}));
951
988
EXPECT_FALSE (snapshot.metadata ().has_pending_writes ());
@@ -979,10 +1016,12 @@ TEST_F(FirestoreIntegrationTest,
979
1016
ListenerRegistration registration = listener.AttachTo (&document);
980
1017
WriteDocument (document, MapFieldValue{{" a" , FieldValue::Double (1.0 )}});
981
1018
Await (listener);
1019
+ EXPECT_TRUE (listener.last_result ().exists ());
982
1020
EXPECT_THAT (listener.last_result ().GetData (),
983
1021
ContainerEq (MapFieldValue{{" a" , FieldValue::Double (1.0 )}}));
984
1022
WriteDocument (document, MapFieldValue{{" b" , FieldValue::Double (1.0 )}});
985
1023
Await (listener);
1024
+ EXPECT_TRUE (listener.last_result ().exists ());
986
1025
EXPECT_THAT (listener.last_result ().GetData (),
987
1026
ContainerEq (MapFieldValue{{" b" , FieldValue::Double (1.0 )}}));
988
1027
registration.Remove ();
@@ -1100,6 +1139,7 @@ TEST_F(FirestoreIntegrationTest, TestCanQueueWritesWhileOffline) {
1100
1139
1101
1140
// Assert
1102
1141
DocumentSnapshot snapshot = ReadDocument (document);
1142
+ EXPECT_TRUE (snapshot.exists ());
1103
1143
EXPECT_THAT (
1104
1144
snapshot.GetData (),
1105
1145
ContainerEq (MapFieldValue{
@@ -1126,6 +1166,7 @@ TEST_F(FirestoreIntegrationTest, TestCanGetDocumentsWhileOffline) {
1126
1166
1127
1167
// The network is offline and we return a cached result.
1128
1168
DocumentSnapshot snapshot = ReadDocument (document);
1169
+ EXPECT_TRUE (snapshot.exists ());
1129
1170
EXPECT_THAT (
1130
1171
snapshot.GetData (),
1131
1172
ContainerEq (MapFieldValue{
@@ -1139,6 +1180,7 @@ TEST_F(FirestoreIntegrationTest, TestCanGetDocumentsWhileOffline) {
1139
1180
Await (TestFirestore ()->EnableNetwork ());
1140
1181
Await (pending_write);
1141
1182
snapshot = ReadDocument (document);
1183
+ EXPECT_TRUE (snapshot.exists ());
1142
1184
EXPECT_THAT (
1143
1185
snapshot.GetData (),
1144
1186
ContainerEq (MapFieldValue{
@@ -1298,6 +1340,7 @@ TEST_F(FirestoreIntegrationTest, RestartFirestoreLeadsToNewInstance) {
1298
1340
DocumentReference doc2 = db2->Document (doc_path);
1299
1341
const DocumentSnapshot* snapshot2 = Await (doc2.Get (Source::kCache ));
1300
1342
ASSERT_NE (snapshot2, nullptr );
1343
+ EXPECT_TRUE (snapshot2->exists ());
1301
1344
EXPECT_THAT (snapshot2->GetData (),
1302
1345
ContainerEq (MapFieldValue{{" foo" , FieldValue::String (" bar" )}}));
1303
1346
@@ -1378,6 +1421,7 @@ TEST_F(FirestoreIntegrationTest, CanClearPersistenceTestHarnessVerification) {
1378
1421
DocumentReference document_2 = db_2->Document (path);
1379
1422
Future<DocumentSnapshot> get_future = document_2.Get (Source::kCache );
1380
1423
DocumentSnapshot snapshot_2 = *Await (get_future);
1424
+ EXPECT_TRUE (snapshot_2.exists ());
1381
1425
EXPECT_THAT (snapshot_2.GetData (),
1382
1426
ContainerEq (MapFieldValue{{" foo" , FieldValue::Integer (42 )}}));
1383
1427
}
0 commit comments