use std::io::Write;
use wallust::{
args::Cli,
args::Globals,
config::Config,
};
#[test]
fn verify_cli() {
use clap::CommandFactory;
Cli::command().debug_assert()
}
#[allow(non_upper_case_globals)]
const content: &str = include_str!("../wallust.toml");
#[test]
fn config_file() {
let mut tmp = tempfile::NamedTempFile::new().expect("init new temporal named pipe");
let g = Globals { config_file: Some(tmp.path().to_path_buf()), ..Globals::default() };
write!(tmp, "{content}").expect("should write to tmp correctly");
let conf_dir = dirs::config_dir().unwrap();
let c = Config::new(&g).expect("should deserialize wallust.toml");
assert_eq!(c.dir, conf_dir.join("wallust"));
assert_eq!(c.file, tmp.path().to_path_buf());
tmp.close().expect("temporal named pipe should close successfully");
}
#[test]
fn config_dir() {
use std::fs::File;
let tmp = tempfile::tempdir().expect("init new temporal named pipe");
let joined = tmp.path().join("wallust.toml");
let mut conf_tmp = File::create(joined).expect("should created a tmp file");
write!(conf_tmp, "{content}").expect("should write to tmp correctly");
let g = Globals { config_dir: Some(tmp.path().to_path_buf()), ..Globals::default() };
let c = Config::new(&g).expect("should deserialize wallust.toml");
assert_eq!(c.dir, tmp.path().to_path_buf());
assert_eq!(c.file, tmp.path().join("wallust.toml").to_path_buf());
tmp.close().expect("temporal directory should close successfully");
}