mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 01:24:58 +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:
@ -52,7 +52,7 @@ fn config_add_unsupported_key() {
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("$env.config.foo is an unknown config setting"));
|
||||
.contains("Unknown config option: $env.config.foo"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -61,7 +61,7 @@ fn config_add_unsupported_type() {
|
||||
r#"$env.config.ls = '' "#,
|
||||
r#";"#]));
|
||||
|
||||
assert!(actual.err.contains("should be a record"));
|
||||
assert!(actual.err.contains("Type mismatch"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -70,12 +70,8 @@ fn config_add_unsupported_value() {
|
||||
r#"$env.config.history.file_format = ''"#,
|
||||
r#";"#]));
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("unrecognized $env.config.history.file_format option ''"));
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("expected either 'sqlite' or 'plaintext'"));
|
||||
assert!(actual.err.contains("Invalid value"));
|
||||
assert!(actual.err.contains("expected 'sqlite' or 'plaintext'"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Reference in New Issue
Block a user