test(terraform): move tests which do not require env vars (#1455)
Co-authored-by: Thomas O'Donnell <andytom@users.noreply.github.com>
This commit is contained in:
parent
297cbd8654
commit
7edd0f6218
|
@ -132,12 +132,6 @@ jobs:
|
|||
if: matrix.os == 'macOS-latest'
|
||||
run: pip3 install mercurial
|
||||
|
||||
# Install Terraform at a fixed version
|
||||
- name: Setup | Terraform
|
||||
uses: volcano-coffee-company/setup-terraform@v1
|
||||
with:
|
||||
version: "0.12.14"
|
||||
|
||||
# Run the ignored tests that expect the above setup
|
||||
- name: Build | Test
|
||||
run: cargo test -- -Z unstable-options --include-ignored
|
||||
|
|
|
@ -97,6 +97,10 @@ fn format_terraform_version(version: &str) -> Option<String> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::modules::utils::test::render_module;
|
||||
use ansi_term::Color;
|
||||
use std::fs::{self, File};
|
||||
use std::io::Write;
|
||||
|
||||
#[test]
|
||||
fn test_format_terraform_version_release() {
|
||||
|
@ -138,4 +142,53 @@ is 0.12.14. You can update by downloading from www.terraform.io/downloads.html
|
|||
Some("v0.12.13 ".to_string())
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn folder_with_dotterraform_with_version_no_environment() -> io::Result<()> {
|
||||
let dir = tempfile::tempdir()?;
|
||||
let tf_dir = dir.path().join(".terraform");
|
||||
fs::create_dir(&tf_dir)?;
|
||||
|
||||
let actual = render_module(
|
||||
"terraform",
|
||||
dir.path(),
|
||||
Some(toml::toml! {
|
||||
[terraform]
|
||||
format = "via [$symbol$version$workspace]($style) "
|
||||
}),
|
||||
);
|
||||
|
||||
let expected = Some(format!(
|
||||
"via {} ",
|
||||
Color::Fixed(105).bold().paint("💠 v0.12.14 default")
|
||||
));
|
||||
assert_eq!(expected, actual);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn folder_with_dotterraform_with_version_with_environment() -> io::Result<()> {
|
||||
let dir = tempfile::tempdir()?;
|
||||
let tf_dir = dir.path().join(".terraform");
|
||||
fs::create_dir(&tf_dir)?;
|
||||
let mut file = File::create(tf_dir.join("environment"))?;
|
||||
file.write_all(b"development")?;
|
||||
file.sync_all()?;
|
||||
|
||||
let actual = render_module(
|
||||
"terraform",
|
||||
dir.path(),
|
||||
Some(toml::toml! {
|
||||
[terraform]
|
||||
format = "via [$symbol$version$workspace]($style) "
|
||||
}),
|
||||
);
|
||||
|
||||
let expected = Some(format!(
|
||||
"via {} ",
|
||||
Color::Fixed(105).bold().paint("💠 v0.12.14 development")
|
||||
));
|
||||
assert_eq!(expected, actual);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,6 +123,10 @@ active boot switches: -d:release\n",
|
|||
stdout: String::from("0.6.0"),
|
||||
stderr: String::default(),
|
||||
}),
|
||||
"terraform version" => Some(CommandOutput {
|
||||
stdout: String::from("Terraform v0.12.14"),
|
||||
stderr: String::default(),
|
||||
}),
|
||||
s if s.starts_with("erl") => Some(CommandOutput {
|
||||
stdout: String::from("22.1.3"),
|
||||
stderr: String::default(),
|
||||
|
|
|
@ -3,7 +3,6 @@ use std::fs::{self, File};
|
|||
use std::io::{self, Write};
|
||||
|
||||
use crate::common;
|
||||
use crate::common::TestCommand;
|
||||
|
||||
#[test]
|
||||
fn folder_without_dotterraform() -> io::Result<()> {
|
||||
|
@ -117,56 +116,3 @@ fn folder_with_dotterraform_with_environment() -> io::Result<()> {
|
|||
assert_eq!(expected, actual);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn folder_with_dotterraform_with_version_no_environment() -> io::Result<()> {
|
||||
let dir = tempfile::tempdir()?;
|
||||
let tf_dir = dir.path().join(".terraform");
|
||||
fs::create_dir(&tf_dir)?;
|
||||
|
||||
let output = common::render_module("terraform")
|
||||
.arg("--path")
|
||||
.arg(dir.path())
|
||||
.use_config(toml::toml! {
|
||||
[terraform]
|
||||
format = "via [$symbol$version$workspace]($style) "
|
||||
})
|
||||
.output()?;
|
||||
let actual = String::from_utf8(output.stdout).unwrap();
|
||||
|
||||
let expected = format!(
|
||||
"via {} ",
|
||||
Color::Fixed(105).bold().paint("💠 v0.12.14 default")
|
||||
);
|
||||
assert_eq!(expected, actual);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn folder_with_dotterraform_with_version_with_environment() -> io::Result<()> {
|
||||
let dir = tempfile::tempdir()?;
|
||||
let tf_dir = dir.path().join(".terraform");
|
||||
fs::create_dir(&tf_dir)?;
|
||||
let mut file = File::create(tf_dir.join("environment"))?;
|
||||
file.write_all(b"development")?;
|
||||
file.sync_all()?;
|
||||
|
||||
let output = common::render_module("terraform")
|
||||
.arg("--path")
|
||||
.arg(dir.path())
|
||||
.use_config(toml::toml! {
|
||||
[terraform]
|
||||
format = "via [$symbol$version$workspace]($style) "
|
||||
})
|
||||
.output()?;
|
||||
let actual = String::from_utf8(output.stdout).unwrap();
|
||||
|
||||
let expected = format!(
|
||||
"via {} ",
|
||||
Color::Fixed(105).bold().paint("💠 v0.12.14 development")
|
||||
);
|
||||
assert_eq!(expected, actual);
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue