mirror of
https://github.com/nushell/nushell.git
synced 2025-08-19 05:25:59 +02:00
Refactor config updates (#13802)
# Description This PR standardizes updates to the config through a new `UpdateFromValue` trait. For now, this trait is private in case we need to make changes to it. Note that this PR adds some additional `ShellError` cases to create standard error messages for config errors. A follow-up PR will move usages of the old error cases to these new ones. This PR also uses `Type::custom` in lots of places (e.g., for string enums). Not sure if this is something we want to encourage. # User-Facing Changes Should be none.
This commit is contained in:
@@ -441,7 +441,7 @@ fn err_hook_wrong_env_type_1() {
|
||||
let actual_repl = nu!(nu_repl_code(inp));
|
||||
dbg!(&actual_repl.err);
|
||||
|
||||
assert!(actual_repl.err.contains("unsupported_config_value"));
|
||||
assert!(actual_repl.err.contains("Type mismatch"));
|
||||
assert_eq!(actual_repl.out, "");
|
||||
}
|
||||
|
||||
@@ -458,7 +458,7 @@ fn err_hook_wrong_env_type_2() {
|
||||
|
||||
let actual_repl = nu!(nu_repl_code(inp));
|
||||
|
||||
assert!(actual_repl.err.contains("type_mismatch"));
|
||||
assert!(actual_repl.err.contains("Type mismatch"));
|
||||
assert_eq!(actual_repl.out, "");
|
||||
}
|
||||
|
||||
@@ -480,7 +480,7 @@ fn err_hook_wrong_env_type_3() {
|
||||
|
||||
let actual_repl = nu!(nu_repl_code(inp));
|
||||
|
||||
assert!(actual_repl.err.contains("unsupported_config_value"));
|
||||
assert!(actual_repl.err.contains("Type mismatch"));
|
||||
assert_eq!(actual_repl.out, "");
|
||||
}
|
||||
|
||||
@@ -503,7 +503,7 @@ fn err_hook_non_boolean_condition_output() {
|
||||
|
||||
let actual_repl = nu!(nu_repl_code(inp));
|
||||
|
||||
assert!(actual_repl.err.contains("unsupported_config_value"));
|
||||
assert!(actual_repl.err.contains("Type mismatch"));
|
||||
assert_eq!(actual_repl.out, "");
|
||||
}
|
||||
|
||||
@@ -526,7 +526,7 @@ fn err_hook_non_condition_not_a_block() {
|
||||
|
||||
let actual_repl = nu!(nu_repl_code(inp));
|
||||
|
||||
assert!(actual_repl.err.contains("unsupported_config_value"));
|
||||
assert!(actual_repl.err.contains("Type mismatch"));
|
||||
assert_eq!(actual_repl.out, "");
|
||||
}
|
||||
|
||||
@@ -548,7 +548,7 @@ fn err_hook_parse_error() {
|
||||
|
||||
let actual_repl = nu!(nu_repl_code(inp));
|
||||
|
||||
assert!(actual_repl.err.contains("unsupported_config_value"));
|
||||
assert!(actual_repl.err.contains("source code has errors"));
|
||||
assert_eq!(actual_repl.out, "");
|
||||
}
|
||||
|
||||
|
@@ -119,7 +119,7 @@ fn mutate_nu_config_plugin() -> TestResult {
|
||||
|
||||
#[test]
|
||||
fn reject_nu_config_plugin_non_record() -> TestResult {
|
||||
fail_test(r#"$env.config.plugins = 5"#, "should be a record")
|
||||
fail_test(r#"$env.config.plugins = 5"#, "Type mismatch")
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -151,7 +151,7 @@ fn mutate_nu_config_plugin_gc_default_stop_after_negative() -> TestResult {
|
||||
$env.config.plugin_gc.default.stop_after = -1sec
|
||||
$env.config.plugin_gc.default.stop_after
|
||||
"#,
|
||||
"must not be negative",
|
||||
"expected a non-negative duration",
|
||||
)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user