fix: remove trailing whitespace from Terraform version (#2726)

This commit is contained in:
Chris 2021-05-16 03:36:59 +01:00 committed by GitHub
parent d0a32b1194
commit ae6c69b13b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 8 deletions

View File

@ -94,8 +94,7 @@ fn get_terraform_version(version: &str) -> Option<String> {
.trim_start_matches("Terraform ") .trim_start_matches("Terraform ")
.trim() .trim()
.trim_start_matches('v') .trim_start_matches('v')
.to_owned() .to_owned(),
+ " ",
) )
} }
@ -110,7 +109,7 @@ mod tests {
#[test] #[test]
fn test_get_terraform_version_release() { fn test_get_terraform_version_release() {
let input = "Terraform v0.12.14"; let input = "Terraform v0.12.14";
assert_eq!(get_terraform_version(input), Some("0.12.14 ".to_string())); assert_eq!(get_terraform_version(input), Some("0.12.14".to_string()));
} }
#[test] #[test]
@ -118,7 +117,7 @@ mod tests {
let input = "Terraform v0.12.14-rc1"; let input = "Terraform v0.12.14-rc1";
assert_eq!( assert_eq!(
get_terraform_version(input), get_terraform_version(input),
Some("0.12.14-rc1 ".to_string()) Some("0.12.14-rc1".to_string())
); );
} }
@ -127,7 +126,7 @@ mod tests {
let input = "Terraform v0.12.14-dev (cca89f74)"; let input = "Terraform v0.12.14-dev (cca89f74)";
assert_eq!( assert_eq!(
get_terraform_version(input), get_terraform_version(input),
Some("0.12.14-dev (cca89f74) ".to_string()) Some("0.12.14-dev (cca89f74)".to_string())
); );
} }
@ -139,7 +138,7 @@ Your version of Terraform is out of date! The latest version
is 0.12.14. You can update by downloading from www.terraform.io/downloads.html is 0.12.14. You can update by downloading from www.terraform.io/downloads.html
"; ";
assert_eq!(get_terraform_version(input), Some("0.12.13 ".to_string())); assert_eq!(get_terraform_version(input), Some("0.12.13".to_string()));
} }
#[test] #[test]
@ -152,7 +151,7 @@ is 0.12.14. You can update by downloading from www.terraform.io/downloads.html
.path(dir.path()) .path(dir.path())
.config(toml::toml! { .config(toml::toml! {
[terraform] [terraform]
format = "via [$symbol$version$workspace]($style) " format = "via [$symbol$version $workspace]($style) "
}) })
.collect(); .collect();
@ -177,7 +176,7 @@ is 0.12.14. You can update by downloading from www.terraform.io/downloads.html
.path(dir.path()) .path(dir.path())
.config(toml::toml! { .config(toml::toml! {
[terraform] [terraform]
format = "via [$symbol$version$workspace]($style) " format = "via [$symbol$version $workspace]($style) "
}) })
.collect(); .collect();