From 64e0208708736185d2e4a23d9c2b98684dd480b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8B=E3=82=8F=E3=81=88=E3=82=82=E3=82=93?= Date: Wed, 11 Jan 2023 18:51:39 +0900 Subject: [PATCH] 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. --- src/modules/aws.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/modules/aws.rs b/src/modules/aws.rs index 014f6b77..ec21408e 100644 --- a/src/modules/aws.rs +++ b/src/modules/aws.rs @@ -802,10 +802,14 @@ aws_secret_access_key=dummy #[test] fn missing_any_credentials() -> io::Result<()> { 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] region = us-east-1 output = json @@ -818,6 +822,10 @@ region = us-east-2 let actual = ModuleRenderer::new("aws") .env("AWS_CONFIG_FILE", config_path.to_string_lossy().as_ref()) + .env( + "AWS_CREDENTIALS_FILE", + credential_path.to_string_lossy().as_ref(), + ) .collect(); let expected = None;