Skip to content
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

Add method to config that uses an empty test environment #3555

Merged
merged 3 commits into from
Dec 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume we're not gating this behind test-utils or anything (aws-config already has quite a few features to the point that it's not friendly to cargo hack --feature-powerset)

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
Loading