googleapis / googleapis/google-cloud-rust
Consider offering testing helpers, gated by a testing feature
- Dominant language
- Rust
- Stars
- 955
- Forks
- 144
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 279
Description
Consumers of the cloud client libraries will need to write repetitive boilerplate code in their tests.
For example, mocking LROs require boilerplate code to create a LRO. Everyone who mocks an LRO needs to do this. We can offer code like:
```rs
fn make_finished_operation(
response: &T,
) -> Result
where T: ... {
let any = wkt::Any::try_from(response)?;
let operation = longrunning::model::Operation::new()
.set_done(true)
.set_result(longrunning::model::operation::Result::Response(any.into()));
Ok(operation)
}
```
I think we should put these into a:
```rs
#[cfg(feature = "testing")]
mod testing {
// types useful for testing go in here
}
```
This module would be part of our public API.
The `testing` feature is not enabled by default. It is enabled in our docs. It is enabled in our testing (because we will likely find these helpers useful too).
Note that `auth` already has something like this: `test_credentials()`.
As always, we should be wary of how adding features explodes the test matrix.
Contributor guide
Assessment
This issue has not been assessed yet.