Skip to content

Commit

Permalink
Add tests for new aws.profile_aliases feature
Browse files Browse the repository at this point in the history
  • Loading branch information
aes committed Mar 9, 2022
1 parent 502d830 commit bf86828
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/modules/aws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,50 @@ mod tests {
assert_eq!(expected, actual);
}

#[test]
fn profile_set_with_alias() {
let actual = ModuleRenderer::new("aws")
.env("AWS_PROFILE", "CORPORATION-CORP_astronauts_ACCESS_GROUP")
.env("AWS_REGION", "ap-northeast-2")
.env("AWS_ACCESS_KEY_ID", "dummy")
.config(toml::toml! {
[aws.profile_aliases]
CORPORATION-CORP_astronauts_ACCESS_GROUP = "astro"
})
.collect();
let expected = Some(format!(
"on {}",
Color::Yellow
.bold()
.paint("鈽侊笍 astro (ap-northeast-2) ")
));

assert_eq!(expected, actual);
}

#[test]
fn region_and_profile_both_set_with_alias() {
let actual = ModuleRenderer::new("aws")
.env("AWS_PROFILE", "CORPORATION-CORP_astronauts_ACCESS_GROUP")
.env("AWS_REGION", "ap-southeast-2")
.env("AWS_ACCESS_KEY_ID", "dummy")
.config(toml::toml! {
[aws.profile_aliases]
CORPORATION-CORP_astronauts_ACCESS_GROUP = "astro"
[aws.region_aliases]
ap-southeast-2 = "au"
})
.collect();
let expected = Some(format!(
"on {}",
Color::Yellow
.bold()
.paint("鈽侊笍 astro (au) ")
));

assert_eq!(expected, actual);
}

#[test]
fn credentials_file_is_ignored_when_is_directory() -> io::Result<()> {
let dir = tempfile::tempdir()?;
Expand Down

0 comments on commit bf86828

Please sign in to comment.