diff --git a/firestore/integration_test_internal/src/write_batch_test.cc b/firestore/integration_test_internal/src/write_batch_test.cc index dadb67107..c9f7311cf 100644 --- a/firestore/integration_test_internal/src/write_batch_test.cc +++ b/firestore/integration_test_internal/src/write_batch_test.cc @@ -19,6 +19,7 @@ #include "firebase/firestore.h" #include "firestore_integration_test.h" #include "util/event_accumulator.h" +#include "util/future_test_util.h" #if defined(__ANDROID__) #include "firestore/src/android/write_batch_android.h" #include "firestore/src/common/wrapper_assertions.h" @@ -145,7 +146,7 @@ TEST_F(WriteBatchTest, TestBatchesCommitAtomicallyRaisingCorrectEvents) { EventAccumulator accumulator; accumulator.listener()->AttachTo(&collection, MetadataChanges::kInclude); QuerySnapshot initial_snapshot = accumulator.Await(); - EXPECT_TRUE(0 == initial_snapshot.size()); + EXPECT_EQ(initial_snapshot.size(), 0); // Atomically write two documents. Await(TestFirestore() @@ -176,7 +177,7 @@ TEST_F(WriteBatchTest, TestBatchesFailAtomicallyRaisingCorrectEvents) { EventAccumulator accumulator; accumulator.listener()->AttachTo(&collection, MetadataChanges::kInclude); QuerySnapshot initial_snapshot = accumulator.Await(); - EXPECT_TRUE(0 == initial_snapshot.size()); + EXPECT_EQ(initial_snapshot.size(), 0); // Atomically write 1 document and update a nonexistent document. Future future = @@ -186,8 +187,10 @@ TEST_F(WriteBatchTest, TestBatchesFailAtomicallyRaisingCorrectEvents) { .Update(doc_b, MapFieldValue{{"b", FieldValue::Integer(2)}}) .Commit(); Await(future); - EXPECT_TRUE(FutureStatus::kFutureStatusComplete == future.status()); - EXPECT_TRUE(Error::kErrorNotFound == future.error()); + EXPECT_EQ(future.status(), FutureStatus::kFutureStatusComplete) + << ToEnumeratorName(future.status()); + EXPECT_EQ(future.error(), Error::kErrorNotFound) + << ToFirestoreErrorCodeName(future.error()); // Local event with the set document. QuerySnapshot local_snapshot = accumulator.Await(); @@ -199,7 +202,7 @@ TEST_F(WriteBatchTest, TestBatchesFailAtomicallyRaisingCorrectEvents) { // Server event with the set reverted QuerySnapshot server_snapshot = accumulator.Await(); EXPECT_FALSE(server_snapshot.metadata().has_pending_writes()); - EXPECT_TRUE(0 == server_snapshot.size()); + EXPECT_EQ(server_snapshot.size(), 0); } TEST_F(WriteBatchTest, TestWriteTheSameServerTimestampAcrossWrites) { @@ -209,7 +212,7 @@ TEST_F(WriteBatchTest, TestWriteTheSameServerTimestampAcrossWrites) { EventAccumulator accumulator; accumulator.listener()->AttachTo(&collection, MetadataChanges::kInclude); QuerySnapshot initial_snapshot = accumulator.Await(); - EXPECT_TRUE(0 == initial_snapshot.size()); + EXPECT_EQ(initial_snapshot.size(), 0); // Atomically write two documents with server timestamps. Await(TestFirestore() @@ -227,9 +230,9 @@ TEST_F(WriteBatchTest, TestWriteTheSameServerTimestampAcrossWrites) { QuerySnapshot server_snapshot = accumulator.AwaitRemoteEvent(); EXPECT_FALSE(server_snapshot.metadata().has_pending_writes()); - EXPECT_TRUE(2 == server_snapshot.size()); + ASSERT_EQ(server_snapshot.size(), 2); const FieldValue when = server_snapshot.documents()[0].Get("when"); - EXPECT_TRUE(FieldValue::Type::kTimestamp == when.type()); + EXPECT_EQ(when.type(), FieldValue::Type::kTimestamp); EXPECT_THAT(QuerySnapshotToValues(server_snapshot), testing::ElementsAre(MapFieldValue{{"when", when}}, MapFieldValue{{"when", when}})); @@ -261,7 +264,7 @@ TEST_F(WriteBatchTest, TestCanWriteTheSameDocumentMultipleTimes) { DocumentSnapshot server_snapshot = accumulator.Await(); EXPECT_FALSE(server_snapshot.metadata().has_pending_writes()); const FieldValue when = server_snapshot.Get("when"); - EXPECT_TRUE(FieldValue::Type::kTimestamp == when.type()); + EXPECT_EQ(when.type(), FieldValue::Type::kTimestamp); EXPECT_THAT(server_snapshot.GetData(), testing::ContainerEq(MapFieldValue{{"a", FieldValue::Integer(1)}, {"b", FieldValue::Integer(2)},