1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-12-01 01:04:00 +00:00

chore(aws): fix unintended test failure of aws::missing_any_credentials (#4805)

chore(aws): fix unintended test failure of `aws::missing_any_credentials` 

Because its mocking is not enough, The test may unintentionally fail
if `~/.aws/credentials` exists.
This commit fixes this issue by mocking `credentials` file as well.
This commit is contained in:
かわえもん 2023-01-11 18:51:39 +09:00 committed by GitHub
parent e88484d567
commit 64e0208708
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -802,10 +802,14 @@ aws_secret_access_key=dummy
#[test] #[test]
fn missing_any_credentials() -> io::Result<()> { fn missing_any_credentials() -> io::Result<()> {
let dir = tempfile::tempdir()?; let dir = tempfile::tempdir()?;
let config_path = dir.path().join("config");
let mut file = File::create(&config_path)?;
file.write_all( let credential_path = dir.path().join("credentials");
File::create(&credential_path)?;
let config_path = dir.path().join("config");
let mut config_file = File::create(&config_path)?;
config_file.write_all(
"[default] "[default]
region = us-east-1 region = us-east-1
output = json output = json
@ -818,6 +822,10 @@ region = us-east-2
let actual = ModuleRenderer::new("aws") let actual = ModuleRenderer::new("aws")
.env("AWS_CONFIG_FILE", config_path.to_string_lossy().as_ref()) .env("AWS_CONFIG_FILE", config_path.to_string_lossy().as_ref())
.env(
"AWS_CREDENTIALS_FILE",
credential_path.to_string_lossy().as_ref(),
)
.collect(); .collect();
let expected = None; let expected = None;