Google Cloud Bigtable C++ Client 2.13.0
A C++ Client Library for Google Cloud Bigtable
Loading...
Searching...
No Matches
mock_row_reader.h
1// Copyright 2022 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_MOCKS_MOCK_ROW_READER_H
16#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_MOCKS_MOCK_ROW_READER_H
17
18#include "google/cloud/bigtable/row_reader.h"
19#include "google/cloud/version.h"
20
21namespace google {
22namespace cloud {
23namespace bigtable_mocks {
24GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
25
26/**
27 * Returns a `RowReader` with a fixed output stream.
28 *
29 * This factory function is offered for customers to mock the output of
30 * `Table::ReadRows(...)` in their tests.
31 *
32 * @note If `Cancel()` is called on the `RowReader`, the stream will terminate
33 * and return `final_status`.
34 *
35 * @param rows a vector containing the `Row`s returned by iterating over the
36 * `RowReader`.
37 *
38 * @param final_status the final Status of the stream. Defaults to OK.
39 *
40 * @code
41 * TEST(ReadRowsTest, Success) {
42 * using ::google::cloud::StatusOr;
43 * using cbt = ::google::cloud::bigtable;
44 * using cbtm = ::google::cloud::bigtable_mocks;
45 *
46 * std::vector<cbt::Row> rows = {cbt::Row("r1", {}), cbt::Row("r2", {})};
47 *
48 * auto mock = std::shared_ptr<cbtm::MockDataConnection>();
49 * EXPECT_CALL(*mock, ReadRowsFull)
50 * .WillOnce(Return(cbtm::MakeRowReader(rows)));
51 *
52 * auto table = cbt::Table(mock);
53 * auto reader = table.ReadRows(...);
54 *
55 * // Verify your code works when reading rows: {"r1", "r2"}
56 * }
57 * @endcode
58 */
59bigtable::RowReader MakeRowReader(std::vector<bigtable::Row> rows,
60 Status final_status = {});
61
62GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
63} // namespace bigtable_mocks
64} // namespace cloud
65} // namespace google
66
67#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_MOCKS_MOCK_ROW_READER_H
Object returned by Table::ReadRows(), enumerates rows in the response.
Definition: row_reader.h:54
The in-memory representation of a Bigtable row.
Definition: row.h:34
Definition: mock_data_connection.h:24
bigtable::RowReader MakeRowReader(std::vector< bigtable::Row > rows, Status final_status={})
Returns a RowReader with a fixed output stream.
Contains all the Cloud Bigtable C++ client APIs.
Definition: admin_client.h:28