Skip to content

Commit

Permalink
Add method to config that uses an empty test environment (#3555)
Browse files Browse the repository at this point in the history
## Motivation and Context
Improve testability

## 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._

---------

Co-authored-by: Zelda Hessler <[email protected]>
  • Loading branch information
rcoh and Velfi authored Dec 24, 2024
1 parent 5fe6dca commit 97ff93f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions aws/rust-runtime/aws-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,16 @@ mod loader {
ret
}

/// Ignore any environment variables on the host during config resolution
///
/// This allows for testing in a reproducible environment that ensures any
/// environment variables from the host do not influence environment variable
/// resolution.
pub fn empty_test_environment(mut self) -> Self {
self.env = Some(Env::from_slice(&[]));
self
}

/// Override the access token provider used to build [`SdkConfig`].
///
/// # Examples
Expand Down Expand Up @@ -782,6 +792,7 @@ mod loader {
.region()
.await
};
let conf = conf.with_region(region.clone());

let retry_config = if let Some(retry_config) = self.retry_config {
retry_config
Expand Down

0 comments on commit 97ff93f

Please sign in to comment.