Enables the Default Config Test

The split of test/no_test happens now in
find_config_dir, it always returns Null in tests.
That way differing configurations in tests shouldn't
make the test fail anymore.
This commit is contained in:
a-kenji 2021-05-02 18:46:36 +02:00
parent ecd3efc3e1
commit 3f3d10e636
2 changed files with 12 additions and 8 deletions

View file

@ -199,12 +199,10 @@ mod config_test {
assert_eq!(result.unwrap(), Config::default()); assert_eq!(result.unwrap(), Config::default());
} }
// This test needs a split somewhere between test and normal runs, #[test]
// since otherwise it would look in a local configuration and fail. fn try_from_cli_args_default() {
//#[test] let opts = CliArgs::default();
//fn try_from_cli_args_default() { let result = Config::try_from(&opts);
//let opts = CliArgs::default(); assert_eq!(result.unwrap(), Config::default());
//let result = Config::try_from(&opts); }
//assert_eq!(result.unwrap(), Config::default());
//}
} }

View file

@ -48,6 +48,7 @@ pub mod install {
} }
} }
#[cfg(not(test))]
pub fn find_default_config_dir() -> Option<PathBuf> { pub fn find_default_config_dir() -> Option<PathBuf> {
vec![ vec![
Some(xdg_config_dir()), Some(xdg_config_dir()),
@ -60,6 +61,11 @@ pub fn find_default_config_dir() -> Option<PathBuf> {
.flatten() .flatten()
} }
#[cfg(test)]
pub fn find_default_config_dir() -> Option<PathBuf> {
None
}
pub fn xdg_config_dir() -> PathBuf { pub fn xdg_config_dir() -> PathBuf {
let project_dirs = ProjectDirs::from("org", "Zellij Contributors", "Zellij").unwrap(); let project_dirs = ProjectDirs::from("org", "Zellij Contributors", "Zellij").unwrap();
project_dirs.config_dir().to_owned() project_dirs.config_dir().to_owned()