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

test(aws): fix flaky tests expiration_date_set expiration_date_set_from_file (#5685)

* fix(aws): fix flaky test `expiration_date_set`

* fix(aws): fix flaky test `expiration_date_set_from_file`
This commit is contained in:
Xiaohan Ni 2024-01-07 05:49:27 +08:00 committed by GitHub
parent 2bb57cf0cd
commit ef7b773557
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -703,14 +703,21 @@ credential_process = /opt/bin/awscreds-retriever
now_plus_half_hour.to_rfc3339_opts(SecondsFormat::Secs, true), now_plus_half_hour.to_rfc3339_opts(SecondsFormat::Secs, true),
) )
.collect(); .collect();
let expected = Some(format!(
"on {}",
Color::Yellow
.bold()
.paint("☁️ astronauts (ap-northeast-2) [30m] ")
));
assert_eq!(expected, actual); let possible_values = [
"30m2s", "30m1s", "30m", "29m59s", "29m58s", "29m57s", "29m56s", "29m55s",
];
let possible_values = possible_values.map(|duration| {
let segment_colored = format!("☁️ astronauts (ap-northeast-2) [{duration}] ");
Some(format!(
"on {}",
Color::Yellow.bold().paint(segment_colored)
))
});
assert!(
possible_values.contains(&actual),
"time is not in range: {actual:?}"
);
}); });
} }
@ -743,46 +750,32 @@ aws_secret_access_key=dummy
) )
.unwrap(); .unwrap();
let actual = ModuleRenderer::new("aws") let credentials_env_vars = ["AWS_SHARED_CREDENTIALS_FILE", "AWS_CREDENTIALS_FILE"];
.env("AWS_PROFILE", "astronauts") credentials_env_vars.iter().for_each(|env_var| {
.env("AWS_REGION", "ap-northeast-2") let actual = ModuleRenderer::new("aws")
.env( .env("AWS_PROFILE", "astronauts")
"AWS_SHARED_CREDENTIALS_FILE", .env("AWS_REGION", "ap-northeast-2")
credentials_path.to_string_lossy().as_ref(), .env(env_var, credentials_path.to_string_lossy().as_ref())
) .collect();
.collect();
let actual_variant = ModuleRenderer::new("aws") // In principle, "30m" should be correct. However, bad luck in scheduling
.env("AWS_PROFILE", "astronauts") // on shared runners may delay it.
.env("AWS_REGION", "ap-northeast-2") let possible_values = [
.env( "30m2s", "30m1s", "30m", "29m59s", "29m58s", "29m57s", "29m56s", "29m55s",
"AWS_CREDENTIALS_FILE", ];
credentials_path.to_string_lossy().as_ref(), let possible_values = possible_values.map(|duration| {
) let segment_colored = format!("☁️ astronauts (ap-northeast-2) [{duration}] ");
.collect(); Some(format!(
"on {}",
Color::Yellow.bold().paint(segment_colored)
))
});
assert_eq!( assert!(
actual, actual_variant, possible_values.contains(&actual),
"both AWS_SHARED_CREDENTIALS_FILE and AWS_CREDENTIALS_FILE should work" "time is not in range: {actual:?}"
); );
// In principle, "30m" should be correct. However, bad luck in scheduling
// on shared runners may delay it.
let possible_values = [
"30m2s", "30m1s", "30m", "29m59s", "29m58s", "29m57s", "29m56s", "29m55s",
];
let possible_values = possible_values.map(|duration| {
let segment_colored = format!("☁️ astronauts (ap-northeast-2) [{duration}] ");
Some(format!(
"on {}",
Color::Yellow.bold().paint(segment_colored)
))
}); });
assert!(
possible_values.contains(&actual),
"time is not in range: {actual:?}"
);
}); });
dir.close() dir.close()