30
30
#include " gmock/gmock.h"
31
31
#include " gtest/gtest.h"
32
32
#include " util/event_accumulator.h"
33
+ #include " util/future_test_util.h"
33
34
#if defined(__ANDROID__)
34
35
#include " firestore/src/android/transaction_android.h"
35
36
#endif // defined(__ANDROID__)
@@ -743,7 +744,8 @@ TEST_F(TransactionTest, TestMaxAttempts) {
743
744
744
745
Future<void > run_transaction_future = firestore->RunTransaction (
745
746
options,
746
- [update_count, &doc](Transaction& transaction, std::string&) -> Error {
747
+ [update_count, &doc](Transaction& transaction,
748
+ std::string& error_message) -> Error {
747
749
SCOPED_TRACE (" Update callback; update_count=" +
748
750
std::to_string (update_count->load ()));
749
751
++(*update_count);
@@ -752,12 +754,14 @@ TEST_F(TransactionTest, TestMaxAttempts) {
752
754
{
753
755
SCOPED_TRACE (" transaction.Get()" );
754
756
Error error = Error::kErrorOk ;
755
- std::string error_message ;
756
- transaction.Get (doc, &error, &error_message );
757
+ std::string get_error_message ;
758
+ transaction.Get (doc, &error, &get_error_message );
757
759
if (error != kErrorOk ) {
758
- ADD_FAILURE () << " transaction.Get() failed: " << error_message
759
- << " (error code " << error << " )" ;
760
- return Error::kErrorInternal ;
760
+ ADD_FAILURE () << " transaction.Get() failed at Checkpoint UCA: "
761
+ << get_error_message << " (error code " << error
762
+ << " ==" << ToFirestoreErrorCodeName (error) << " )" ;
763
+ error_message = " Test failed in update callback at Checkpoint UCA" ;
764
+ return Error::kErrorInvalidArgument ;
761
765
}
762
766
}
763
767
@@ -768,12 +772,20 @@ TEST_F(TransactionTest, TestMaxAttempts) {
768
772
doc.Set ({{" count" , FieldValue::Integer (update_count->load ())}});
769
773
set_future.Await (10000L );
770
774
if (set_future.status () != FutureStatus::kFutureStatusComplete ) {
771
- ADD_FAILURE () << " Timeout waiting for doc.Set() to complete" ;
772
- return Error::kErrorInternal ;
775
+ ADD_FAILURE () << " Timeout waiting for doc.Set() to complete at "
776
+ " Checkpoint UCB; status() returned: "
777
+ << set_future.status ()
778
+ << " ==" << ToEnumeratorName (set_future.status ());
779
+ error_message = " Test failed in update callback at Checkpoint UCB" ;
780
+ return Error::kErrorInvalidArgument ;
773
781
} else if (set_future.error () != Error::kErrorOk ) {
774
- ADD_FAILURE () << " doc.Set() failed: " << set_future.error_message ()
775
- << " (error code " << set_future.error () << " )" ;
776
- return Error::kErrorInternal ;
782
+ ADD_FAILURE () << " doc.Set() failed at Checkpoint UCC: "
783
+ << set_future.error_message () << " (error code "
784
+ << set_future.error () << " =="
785
+ << ToFirestoreErrorCodeName (set_future.error ())
786
+ << " )" ;
787
+ error_message = " Test failed in update callback at Checkpoint UCC" ;
788
+ return Error::kErrorInvalidArgument ;
777
789
}
778
790
}
779
791
@@ -790,9 +802,16 @@ TEST_F(TransactionTest, TestMaxAttempts) {
790
802
SCOPED_TRACE (" Waiting for Future returned from RunTransaction()" );
791
803
Await (run_transaction_future);
792
804
ASSERT_EQ (run_transaction_future.status (),
793
- FutureStatus::kFutureStatusComplete );
794
- EXPECT_EQ (run_transaction_future.error (), Error::kErrorFailedPrecondition )
795
- << " error message: " << run_transaction_future.error_message ();
805
+ FutureStatus::kFutureStatusComplete )
806
+ << " run_transaction_future.status() returned: "
807
+ << run_transaction_future.status ()
808
+ << " ==" << ToEnumeratorName (run_transaction_future.status ());
809
+ ASSERT_EQ (run_transaction_future.error (), Error::kErrorFailedPrecondition )
810
+ << " error message: " << run_transaction_future.error_message ()
811
+ << " (run_transaction_future.error() returned "
812
+ << run_transaction_future.error ()
813
+ << " ==" << ToFirestoreErrorCodeName (run_transaction_future.error ())
814
+ << " )" ;
796
815
}
797
816
798
817
EXPECT_EQ (update_count->load (), 3 );
0 commit comments