mod utils;
use crate::utils::{setup, write_to_file};
use anyhow::Result;
#[test]
fn test_cli_config_without_config() -> Result<()> {
let expected = r#"shell = "sh -c '{}'"
[[items]]
name = "base16-shell"
path = "https://github.com/tinted-theming/base16-shell"
hook = ". %f"
supported-systems = ["base16"]
themes-dir = "scripts"
"#;
let (_, _, command_vec, cleanup) = setup("test_cli_config_without_config", "config")?;
let (stdout, _) = utils::run_command(command_vec).unwrap();
assert_eq!(stdout, expected);
cleanup()?;
Ok(())
}
#[test]
fn test_cli_config_with_config() -> Result<()> {
let config_text = r#"shell = "zsh -c '{}'"
default-scheme = "base16-oceanicnext"
[[items]]
name = "tinted-vim"
path = "https://github.com/tinted-theming/tinted-vim"
supported-systems = ["base16", "base24"]
themes-dir = "colors"
"#;
let (config_path, _, command_vec, cleanup) = setup("test_cli_config_with_config", "config")?;
write_to_file(&config_path, config_text)?;
let (stdout, _) = utils::run_command(command_vec).unwrap();
assert_eq!(stdout, config_text);
cleanup()?;
Ok(())
}
#[test]
fn test_cli_config_with_config_flag() -> Result<()> {
let (config_path, _, command_vec, cleanup) =
setup("test_cli_config_with_config_flag", "config --config-path")?;
let (stdout, _) = utils::run_command(command_vec).unwrap();
assert!(
stdout.contains(format!("{}", config_path.display()).as_str()),
"stdout does not contain the expected output"
);
cleanup()?;
Ok(())
}
#[test]
fn test_cli_config_with_data_flag() -> Result<()> {
let (_, data_path, command_vec, cleanup) =
setup("test_cli_config_with_data_flag", "config --data-dir-path")?;
let (stdout, _) = utils::run_command(command_vec).unwrap();
assert!(
stdout.contains(format!("{}", data_path.display()).as_str()),
"stdout does not contain the expected output"
);
cleanup()?;
Ok(())
}