Class MockConnection (2.19.0)

An inlined versioned namespace to avoid dependency diamonds.

A class to mock google::cloud::spanner::Connection.

Application developers may want to test their code with simulated responses, including errors from a spanner::Client. To do so, construct a spanner::Client with an instance of this class. Then use the Google Test framework functions to program the behavior of this mock.

See Also

Mocking the Cloud Spanner C++ Client with Google Mock for an example using this class.

Functions

virtual options()

Returns the options used by the Connection.

This function is implemented using gMock's MOCK_METHOD(). Consult the gMock documentation to use this mock in your tests.

Returns
TypeDescription
Options

virtual Read(ReadParams)

Defines the interface for Client::Read()

This function is implemented using gMock's MOCK_METHOD(). Consult the gMock documentation to use this mock in your tests.

Parameter
NameDescription
ReadParams
Returns
TypeDescription
RowStream

virtual PartitionRead(PartitionReadParams)

Defines the interface for Client::PartitionRead()

This function is implemented using gMock's MOCK_METHOD(). Consult the gMock documentation to use this mock in your tests.

Parameter
NameDescription
PartitionReadParams
Returns
TypeDescription
StatusOr< std::vector< ReadPartition > >

virtual ExecuteQuery(SqlParams)

Defines the interface for Client::ExecuteQuery()

This function is implemented using gMock's MOCK_METHOD(). Consult the gMock documentation to use this mock in your tests.

Parameter
NameDescription
SqlParams
Returns
TypeDescription
RowStream

virtual ExecuteDml(SqlParams)

Defines the interface for Client::ExecuteDml()

This function is implemented using gMock's MOCK_METHOD(). Consult the gMock documentation to use this mock in your tests.

Parameter
NameDescription
SqlParams
Returns
TypeDescription
StatusOr< DmlResult >

virtual ProfileQuery(SqlParams)

Defines the interface for Client::ProfileQuery()

This function is implemented using gMock's MOCK_METHOD(). Consult the gMock documentation to use this mock in your tests.

Parameter
NameDescription
SqlParams
Returns
TypeDescription
ProfileQueryResult

virtual ProfileDml(SqlParams)

Defines the interface for Client::ProfileDml()

This function is implemented using gMock's MOCK_METHOD(). Consult the gMock documentation to use this mock in your tests.

Parameter
NameDescription
SqlParams
Returns
TypeDescription
StatusOr< ProfileDmlResult >

virtual AnalyzeSql(SqlParams)

Defines the interface for Client::AnalyzeSql()

This function is implemented using gMock's MOCK_METHOD(). Consult the gMock documentation to use this mock in your tests.

Parameter
NameDescription
SqlParams
Returns
TypeDescription
StatusOr< ExecutionPlan >

virtual ExecutePartitionedDml(ExecutePartitionedDmlParams)

Defines the interface for Client::ExecutePartitionedDml()

This function is implemented using gMock's MOCK_METHOD(). Consult the gMock documentation to use this mock in your tests.

Parameter
NameDescription
ExecutePartitionedDmlParams
Returns
TypeDescription
StatusOr< PartitionedDmlResult >

virtual PartitionQuery(PartitionQueryParams)

Defines the interface for Client::PartitionQuery()

This function is implemented using gMock's MOCK_METHOD(). Consult the gMock documentation to use this mock in your tests.

Parameter
NameDescription
PartitionQueryParams
Returns
TypeDescription
StatusOr< std::vector< QueryPartition > >

virtual ExecuteBatchDml(ExecuteBatchDmlParams)

Defines the interface for Client::ExecuteBatchDml()

This function is implemented using gMock's MOCK_METHOD(). Consult the gMock documentation to use this mock in your tests.

Parameter
NameDescription
ExecuteBatchDmlParams
Returns
TypeDescription
StatusOr< BatchDmlResult >

virtual Commit(CommitParams)

Defines the interface for Client::Commit()

This function is implemented using gMock's MOCK_METHOD(). Consult the gMock documentation to use this mock in your tests.

Parameter
NameDescription
CommitParams
Returns
TypeDescription
StatusOr< CommitResult >

virtual Rollback(RollbackParams)

Defines the interface for Client::Rollback()

This function is implemented using gMock's MOCK_METHOD(). Consult the gMock documentation to use this mock in your tests.

Parameter
NameDescription
RollbackParams
Returns
TypeDescription
Status

virtual BatchWrite(BatchWriteParams)

Defines the interface for batched Client::CommitAtLeastOnce()

This function is implemented using gMock's MOCK_METHOD(). Consult the gMock documentation to use this mock in your tests.

Parameter
NameDescription
BatchWriteParams
Returns
TypeDescription
BatchedCommitResultStream