2022-08-23 07:18:14 +00:00
|
|
|
use nu_test_support::nu;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_default_config_path() {
|
|
|
|
let config_dir = nu_path::config_dir().expect("Could not get config directory");
|
|
|
|
let cwd = std::env::current_dir().expect("Could not get current working directory");
|
|
|
|
|
|
|
|
let config_path = config_dir.join("nushell").join("config.nu");
|
2023-01-04 07:59:10 +00:00
|
|
|
let actual = nu!(cwd: &cwd, minimal_config: false, "$nu.config-path");
|
|
|
|
assert_eq!(
|
|
|
|
nu_utils::strip_ansi_string_likely(actual.out),
|
|
|
|
config_path.to_string_lossy().to_string()
|
|
|
|
);
|
2022-08-23 07:18:14 +00:00
|
|
|
|
|
|
|
let env_path = config_dir.join("nushell").join("env.nu");
|
|
|
|
let actual = nu!(cwd: &cwd, "$nu.env-path");
|
2023-01-04 07:59:10 +00:00
|
|
|
assert_eq!(
|
|
|
|
nu_utils::strip_ansi_string_likely(actual.out),
|
|
|
|
env_path.to_string_lossy().to_string()
|
|
|
|
);
|
2022-08-23 07:18:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_alternate_config_path() {
|
|
|
|
let config_file = "crates/nu-utils/src/sample_config/default_config.nu";
|
|
|
|
let env_file = "crates/nu-utils/src/sample_config/default_env.nu";
|
|
|
|
|
|
|
|
let cwd = std::env::current_dir().expect("Could not get current working directory");
|
|
|
|
|
|
|
|
let config_path =
|
|
|
|
nu_path::canonicalize_with(config_file, &cwd).expect("Could not get config path");
|
|
|
|
let actual = nu!(
|
|
|
|
cwd: &cwd,
|
2023-01-04 07:59:10 +00:00
|
|
|
minimal_config: false,
|
2022-08-23 07:18:14 +00:00
|
|
|
format!("nu --config {:?} -c '$nu.config-path'", config_path)
|
|
|
|
);
|
2023-01-04 07:59:10 +00:00
|
|
|
assert_eq!(
|
|
|
|
nu_utils::strip_ansi_string_likely(actual.out),
|
|
|
|
config_path.to_string_lossy().to_string()
|
|
|
|
);
|
2022-08-23 07:18:14 +00:00
|
|
|
|
|
|
|
let env_path = nu_path::canonicalize_with(env_file, &cwd).expect("Could not get env path");
|
|
|
|
let actual = nu!(
|
|
|
|
cwd: &cwd,
|
|
|
|
format!("nu --env-config {:?} -c '$nu.env-path'", env_path)
|
|
|
|
);
|
2023-01-04 07:59:10 +00:00
|
|
|
assert_eq!(
|
|
|
|
nu_utils::strip_ansi_string_likely(actual.out),
|
|
|
|
env_path.to_string_lossy().to_string()
|
|
|
|
);
|
2022-08-23 07:18:14 +00:00
|
|
|
}
|