#[test]
fn import() {
insta::glob!("cli/import/*", |file| {
let format = match file.extension().unwrap().to_string_lossy().as_ref() {
"yml" | "yaml" => "yaml",
"json" => "json",
_ => unreachable!(),
};
let implicit = {
let mut cmd = assert_cmd::Command::cargo_bin("cco").unwrap();
let assert = cmd.arg("import").arg(file.to_str().unwrap()).assert();
String::from_utf8_lossy(assert.success().get_output().stdout.as_ref()).to_string()
};
let explicit = {
let mut cmd = assert_cmd::Command::cargo_bin("cco").unwrap();
let assert = cmd
.arg("import")
.arg("--format")
.arg(format)
.arg(file.to_str().unwrap())
.assert();
String::from_utf8_lossy(assert.success().get_output().stdout.as_ref()).to_string()
};
assert_eq!(
implicit, explicit,
"import with --format={format} and without should yield the same results"
);
insta::assert_snapshot!(implicit);
})
}
#[test]
pub fn evaluate() {
insta::glob!("cli/evaluate/*.hcl", |path| {
let mut cmd = assert_cmd::Command::cargo_bin("cco").unwrap();
let assert = cmd
.arg("evaluate")
.arg("--format=yaml")
.arg(path.to_str().unwrap())
.assert();
let result =
String::from_utf8_lossy(assert.success().get_output().stdout.as_ref()).to_string();
insta::assert_snapshot!(result);
})
}