Class MockConnection (2.16.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
Type Description
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
Name Description
ReadParams
Returns
Type Description
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
Name Description
PartitionReadParams
Returns
Type Description
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
Name Description
SqlParams
Returns
Type Description
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
Name Description
SqlParams
Returns
Type Description
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
Name Description
SqlParams
Returns
Type Description
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
Name Description
SqlParams
Returns
Type Description
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
Name Description
SqlParams
Returns
Type Description
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
Name Description
ExecutePartitionedDmlParams
Returns
Type Description
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
Name Description
PartitionQueryParams
Returns
Type Description
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
Name Description
ExecuteBatchDmlParams
Returns
Type Description
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
Name Description
CommitParams
Returns
Type Description
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
Name Description
RollbackParams
Returns
Type Description
Status