Namespace google::cloud::bigtable_mocks (2.43.0-rc)

Classes

MockDataConnection

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

Functions

MakeQueryRow(std::vector< std::pair< std::string, bigtable::Value > > const &)

Creates a bigtable::QueryRow with the specified column names and values.

This overload accepts a vector of pairs, allowing the caller to specify both the column names and the bigtable::Value that goes in each column.

This function is intended for application developers who are mocking the results of a Client::ReadRows call.

Parameter
Name Description
columns std::vector< std::pair< std::string, bigtable::Value > > const &
Returns
Type Description
bigtable::QueryRow

MakeQueryRow(Ts &&...)

Creates a bigtable::QueryRow with bigtable::Values created from the given arguments and with auto-generated column names.

This overload accepts a variadic list of arguments that will be used to create the bigtable::Values in the row. The column names will be implicitly generated, the first column being "0", the second "1", and so on, corresponding to the argument's position.

This function is intended for application developers who are mocking the results of a Client::ReadRows call.

Parameters
Name Description
values Ts &&...
typename...
Returns
Type Description
bigtable::QueryRow

MakeRowReader(std::vector< bigtable::Row >, 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.

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, ReadRowsFull)
      .WillOnce(Return(cbtm::MakeRowReader(rows)));

  auto table = cbt::Table(mock);
  auto reader = table.ReadRows(...);

  // Verify your code works when reading rows: {"r1", "r2"}
}
Parameters
Name Description
rows std::vector< bigtable::Row >

a vector containing the Rows returned by iterating over the RowReader.

final_status Status

the final Status of the stream. Defaults to OK.

Returns
Type Description
bigtable::RowReader