Publishing is disabled for this package currently.
## Motivation and Context
Testing is a huge pain. Currently. This method isn't ideal and can lack
accuracy in some cases but in quick and useful for many applications.
## Description
New mock package that allows code like this:
```rust
let s3_404 = mock!(Client::get_object)
.match_requests(|inp| {
inp.bucket() == Some("test-bucket") && inp.key() != Some("correct-key")
})
.then_http_response(|| {
http::Response::builder()
.status(400)
.body(SdkBody::from(S3_NO_SUCH_KEY))
.unwrap()
.try_into()
.unwrap()
});
let s3_real_object = mock!(Client::get_object)
.match_requests(|inp| {
inp.bucket() == Some("test-bucket") && inp.key() == Some("correct-key")
})
.then_output(|| {
GetObjectOutput::builder()
.body(ByteStream::from_static(b"test-test-test"))
.build()
});
let get_object_mocks = MockResponseInterceptor::new()
.with_rule(&s3_404)
.with_rule(&s3_real_object);
let s3 = aws_sdk_s3::Client::from_conf(
Config::builder()
.with_test_defaults()
.region(Region::new("us-east-1"))
.interceptor(get_object_mocks)
.build(),
);
```
There is no binary level mocking and this is completely typesafe. IDE
inference works properly as well. The crimes that were committed were
small and self-contained.
## Testing
There is a unit test and it works.
## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [ ] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates
- [ ] I have updated `CHANGELOG.next.toml` if I made changes to the AWS
SDK, generated SDK code, or SDK runtime crates
----
_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._