-
Notifications
You must be signed in to change notification settings - Fork 220
apply us-east-1
as default region if not set by user in with_test_defaults()
#4312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
applies_to: | ||
- client | ||
- aws-sdk-rust | ||
authors: | ||
- aajtodd | ||
references: | ||
- smithy-rs#4265 | ||
- smithy-rs#4189 | ||
breaking: false | ||
new_feature: false | ||
bug_fix: true | ||
--- | ||
Apply `us-east-1` as default region if not set by user in `with_test_defaults()` for all clients supporting region allowing `aws-smithy-mocks` to work for non AWS SDK generated clients. Also clarify `test-util` feature requirement when using `aws-smithy-mocks`. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "aws-smithy-mocks" | ||
version = "0.1.2" | ||
version = "0.2.0" | ||
authors = ["AWS Rust SDK Team <[email protected]>"] | ||
description = "Testing utilities for smithy-rs generated clients" | ||
edition = "2021" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,30 @@ without mocking the entire client or using traits. | |
- **Response Sequencing**: Define sequences of responses for testing retry behavior | ||
- **Rule Modes**: Control how rules are matched and applied | ||
|
||
## Prerequisites | ||
|
||
<div class="warning"> | ||
You must enable the `test-util` feature of the service client crate in order to use the `mock_client` macro. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know its kind of implicit in the example below that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This happens so frequently that I wonder if we should design a really nice error where the mock_client invokes a macro we define in the crates and if test-util isn't enabled it uses compile_fail! To give a precise error. Can't do it here obviously since we'd need to add that macro first in the generated crates |
||
</div> | ||
|
||
If the feature is not enabled a compilation error similar to the following will occur: | ||
|
||
```ignore | ||
no method named with_test_defaults found for struct <service-client-crate>::config::Builder in the current scope | ||
method not found in Builder | ||
``` | ||
|
||
Example `Cargo.toml` using the `aws-sdk-s3` crate as the service client crate under test: | ||
|
||
```toml | ||
[dependencies] | ||
aws-sdk-s3 = "1" | ||
|
||
[test-dependencies] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
aws-smithy-mocks = "0.2" | ||
aws-sdk-s3 = { version = "1", features = ["test-util"] } | ||
``` | ||
|
||
## Basic Usage | ||
|
||
```rust,ignore | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth a BMV for this or other opt-out? I feel like there is a very high probability that someones unit test will be broken by this and although the fix won't be hard they might appreciate a way to hold back to keep their tests working
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our own unit tests are broken by this and I'm not sure whether we want to ship this right now as we have introduced a precedence problem for defaults between
with_test_defaults
and endpoint builtins.Generated test code:
failure:
this test is generated by: https://github.com/smithy-lang/smithy-rs/blob/2016a67af3beeb4c976da9fb3d867f15822e[…]/amazon/smithy/rustsdk/endpoints/OperationInputTestGenerator.kt
Interestingly it shows nothing for builtins
but effectively it's relying on the default builtin value of us-east-2which it would not be now because with_test_defaults sets a different default when unset