You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add then_compute_response method to aws-smithy-mocks (#4388)
Adds a new method that allows developers to stub arbitrary responses
(outputs, errors, or HTTP responses) based on input request properties.
Unlike then_compute_output which only returns successful outputs, this
method enables conditional response generation where the response type
can vary based on the input.
Changes:
- Make MockResponse enum public to allow user construction
- Add RuleBuilder::then_compute_response() method
- Add ResponseSequenceBuilder::compute_response() internal method
- Export MockResponse from lib.rs
- Add integration test demonstrating conditional responses
- Update README with usage example
Example usage:
```
mock!(Client::get_object) .then_compute_response(|req| { if req.key() == Some("error-key") { MockResponse::Error(...) } else { MockResponse::Output(...) } })
```
## Motivation and Context
Allow for stubbing/faking that sends failures back to the caller
## Testing
crate tests
## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [ ] For changes to the smithy-rs codegen or runtime crates, I have
created a changelog entry Markdown file in the `.changelog` directory,
specifying "client," "server," or both in the `applies_to` key.
- [ ] For changes to the AWS SDK, generated SDK code, or SDK runtime
crates, I have created a changelog entry Markdown file in the
`.changelog` directory, specifying "aws-sdk-rust" in the `applies_to`
key.
----
_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
Co-authored-by: Aaron Todd <aajtodd@users.noreply.github.com>
0 commit comments