mod common;
use crate::common::REPO_NAME;
use anyhow::Result;
use common::setup;
use std::fs;
use std::path::Path;
#[test]
fn test_cli_list_subcommand_with_setup() -> Result<()> {
let (config_path, data_path, command_vec, cleanup) =
setup("test_cli_list_subcommand_with_setup", "list")?;
let expected_output = fs::read_to_string(Path::new("fixtures/schemes.txt"))?;
common::run_install_command(&config_path, &data_path)?;
let (stdout, _) = common::run_command(command_vec).unwrap();
let lines: Vec<&str> = expected_output.lines().collect();
for line in lines {
assert!(
stdout.contains(line),
"stdout does not contain the expected output"
);
}
cleanup()?;
Ok(())
}
#[test]
fn test_cli_list_subcommand_without_setup() -> Result<()> {
let (_, _, command_vec, cleanup) = setup("test_cli_list_subcommand_without_setup", "list")?;
let expected_output = format!(
"Schemes are missing, run install and then try again: `{} install`",
REPO_NAME
);
let (_, stderr) = common::run_command(command_vec).unwrap();
assert!(
stderr.contains(&expected_output),
"stdout does not contain the expected output"
);
cleanup()?;
Ok(())
}