From 3f3d10e63606604ccc3b751a7cf2a27bb52292d0 Mon Sep 17 00:00:00 2001 From: a-kenji Date: Sun, 2 May 2021 18:46:36 +0200 Subject: [PATCH] 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. --- src/common/input/config.rs | 14 ++++++-------- src/common/setup.rs | 6 ++++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/common/input/config.rs b/src/common/input/config.rs index 81c041207..3263b5710 100644 --- a/src/common/input/config.rs +++ b/src/common/input/config.rs @@ -199,12 +199,10 @@ mod config_test { assert_eq!(result.unwrap(), Config::default()); } - // This test needs a split somewhere between test and normal runs, - // since otherwise it would look in a local configuration and fail. - //#[test] - //fn try_from_cli_args_default() { - //let opts = CliArgs::default(); - //let result = Config::try_from(&opts); - //assert_eq!(result.unwrap(), Config::default()); - //} + #[test] + fn try_from_cli_args_default() { + let opts = CliArgs::default(); + let result = Config::try_from(&opts); + assert_eq!(result.unwrap(), Config::default()); + } } diff --git a/src/common/setup.rs b/src/common/setup.rs index 9d1e7d19f..70e0ded47 100644 --- a/src/common/setup.rs +++ b/src/common/setup.rs @@ -48,6 +48,7 @@ pub mod install { } } +#[cfg(not(test))] pub fn find_default_config_dir() -> Option { vec![ Some(xdg_config_dir()), @@ -60,6 +61,11 @@ pub fn find_default_config_dir() -> Option { .flatten() } +#[cfg(test)] +pub fn find_default_config_dir() -> Option { + None +} + pub fn xdg_config_dir() -> PathBuf { let project_dirs = ProjectDirs::from("org", "Zellij Contributors", "Zellij").unwrap(); project_dirs.config_dir().to_owned()