docs: user guide for mocking LRO errors#1722
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1722 +/- ##
=======================================
Coverage 96.09% 96.09%
=======================================
Files 54 54
Lines 1998 1998
=======================================
Hits 1920 1920
Misses 78 78 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| The simplest way to simulate an error is to have the initial request fail with | ||
| an error. | ||
|
|
||
| ```rust,ignore,noplayground | ||
| {{#rustdoc_include ../samples/tests/mocking_lros_error.rs:expectation-initial}} | ||
| ``` |
There was a problem hiding this comment.
This is subject to the retry policy. You should say something about returning an error that is not retryable.
There was a problem hiding this comment.
The stubbed out clients do not have policies. I moved the blurb that says that up to the initial section of the error handling. (it was formerly tucked away in the last of the subsections).
| mock.expect_get_operation() | ||
| .once() | ||
| .in_sequence(&mut seq) | ||
| .returning(|_, _| Err(Error::other("could not poll operation"))); |
There was a problem hiding this comment.
I think it would be more interesting to return realistic errors here, like a ServiceError with Code::Aborted or something. If you are writing tests that return errors, it is because your code handles realistic errors, we need to feed it realistic errors too. If not, we should explain that we are using Error::other to simplify the tests, and that real RPCs return something different.
94ba360 to
bdfeb34
Compare
Fixes #1661
Describe how to simulate different types of LRO errors in tests in the user guide.
Looks like: mocking_lros_error.pdf