Class MockAsyncReaderConnection (2.17.0)

Functions

Cancel()

Cancels the current download.

Callers should continue reading until Read() is satisfied with a Status.

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

Returns
Type Description
void

Read()

Asks for more data.

An outcome with a Status indicates that no more data is available. Calling Read() after it returns a Status results in undefined behavior.

Applications should not have more than one Read() pending at a time. Calling Read() while a previous Read() is pending results in undefined behavior.

Applications should not destruct an AsyncReaderConnection until a call to Read() returns a Status response.

Retrieving more data can result in three outcomes:

  • Additional data (a ReadPayload) is available: in this case the future is satisfied with a ReadResponse containing a ReadPayload.
  • The download is interrupted with an error: in this case the future is satisfied with a ReadResponse containing a Status that describes the error.
  • The download has completed successfully: in this case the future is satisfied with a ReadResponse containing an OK Status.

A StatusOr<> cannot represent the last bullet point, so we need an absl::variant<> in this case. We could have used StatusOr<absl::optional<ReadPayload>> but that sounds unnecessarily complicated.

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

Returns
Type Description
future< ReadResponse >

Type Aliases

ReadResponse

Alias Of: absl::variant< ReadPayload, Status >

The value returned by Read(). See the function for more details.