Google Cloud Spanner C++ Client
A C++ Client Library for Google Cloud Spanner
mock_spanner_connection.h
Go to the documentation of this file.
1 // Copyright 2019 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 // http://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_SPANNER_MOCKS_MOCK_SPANNER_CONNECTION_H
16 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_MOCKS_MOCK_SPANNER_CONNECTION_H
17 
22 #include <gmock/gmock.h>
23 
24 namespace google {
25 namespace cloud {
27 namespace spanner_mocks {
29 inline namespace SPANNER_CLIENT_NS {
30 
41 class MockConnection : public spanner::Connection {
42  public:
43  MOCK_METHOD1(Read, spanner::RowStream(ReadParams));
44  MOCK_METHOD1(PartitionRead, StatusOr<std::vector<spanner::ReadPartition>>(
45  PartitionReadParams));
46  MOCK_METHOD1(ExecuteQuery, spanner::RowStream(SqlParams));
47  MOCK_METHOD1(ExecuteDml, StatusOr<spanner::DmlResult>(SqlParams));
48  MOCK_METHOD1(ProfileQuery, spanner::ProfileQueryResult(SqlParams));
49  MOCK_METHOD1(ProfileDml, StatusOr<spanner::ProfileDmlResult>(SqlParams));
50  MOCK_METHOD1(AnalyzeSql, StatusOr<spanner::ExecutionPlan>(SqlParams));
51  MOCK_METHOD1(ExecutePartitionedDml, StatusOr<spanner::PartitionedDmlResult>(
52  ExecutePartitionedDmlParams));
53  MOCK_METHOD1(PartitionQuery, StatusOr<std::vector<spanner::QueryPartition>>(
54  PartitionQueryParams));
55  MOCK_METHOD1(ExecuteBatchDml,
56  StatusOr<spanner::BatchDmlResult>(ExecuteBatchDmlParams));
57  MOCK_METHOD1(Commit, StatusOr<spanner::CommitResult>(CommitParams));
58  MOCK_METHOD1(Rollback, Status(RollbackParams));
59 };
60 
66 class MockResultSetSource : public spanner::internal::ResultSourceInterface {
67  public:
68  MOCK_METHOD0(NextRow, StatusOr<spanner::Row>());
69  MOCK_METHOD0(Metadata, optional<google::spanner::v1::ResultSetMetadata>());
70  MOCK_CONST_METHOD0(Stats, optional<google::spanner::v1::ResultSetStats>());
71 };
72 
73 } // namespace SPANNER_CLIENT_NS
74 } // namespace spanner_mocks
75 } // namespace cloud
76 } // namespace google
77 
78 #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_MOCKS_MOCK_SPANNER_CONNECTION_H
Mock the results of a ExecuteQuery() or Read() operation.
A class to mock google::cloud::spanner::Connection.
#define SPANNER_CLIENT_NS
Definition: version.h:22