Google Cloud Bigtable C++ Client  2.4.0
A C++ Client Library for Google Cloud Bigtable
Classes | Functions
google::cloud::bigtable_mocks Namespace Reference


class  MockDataConnection
 A class to mock google::cloud::bigtable::DataConnection. More...


bigtable::RowReader MakeRowReader (std::vector< bigtable::Row > rows, Status final_status={})
 Returns a RowReader with a fixed output stream. More...

Function Documentation

◆ MakeRowReader()

bigtable::RowReader google::cloud::bigtable_mocks::MakeRowReader ( std::vector< bigtable::Row rows,
Status  final_status = {} 

Returns a RowReader with a fixed output stream.

This factory function is offered for customers to mock the output of Table::ReadRows(...) in their tests.

If Cancel() is called on the RowReader, the stream will terminate and return final_status.
rowsa vector containing the Rows returned by iterating over the RowReader.
final_statusthe final Status of the stream. Defaults to OK.
TEST(ReadRowsTest, Success) {
using ::google::cloud::StatusOr;
using cbt = ::google::cloud::bigtable;
using cbtm = ::google::cloud::bigtable_mocks;
std::vector<cbt::Row> rows = {cbt::Row("r1", {}), cbt::Row("r2", {})};
auto mock = std::shared_ptr<cbtm::MockDataConnection>();
EXPECT_CALL(*mock, ReadRows)
auto table = cbt::Table(mock);
auto reader = table.ReadRows(...);
// Verify your code works when reading rows: {"r1", "r2"}