mirror of
https://github.com/crate-ci/typos.git
synced 2024-12-23 08:02:15 -05:00
test(config): Ensure types are validated
This commit is contained in:
parent
68c0a0d898
commit
a22567c188
1 changed files with 25 additions and 0 deletions
|
@ -342,6 +342,8 @@ impl<'t, 'd> Default for Policy<'t, 'd> {
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
const NEVER_EXIST_TYPE: &str = "this-type-should-never-exist-but-i-hate-you-if-it-does";
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_load_config_applies_overrides() {
|
fn test_load_config_applies_overrides() {
|
||||||
let storage = ConfigStorage::new();
|
let storage = ConfigStorage::new();
|
||||||
|
@ -390,4 +392,27 @@ mod test {
|
||||||
Some(false)
|
Some(false)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_init_fails_on_unknown_type() {
|
||||||
|
let storage = ConfigStorage::new();
|
||||||
|
let mut engine = ConfigEngine::new(&storage);
|
||||||
|
engine.set_isolated(true);
|
||||||
|
|
||||||
|
let type_name = kstring::KString::from_static(NEVER_EXIST_TYPE);
|
||||||
|
|
||||||
|
let config = crate::config::Config {
|
||||||
|
type_: maplit::hashmap! {
|
||||||
|
type_name.clone() => crate::config::TypeEngineConfig {
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
},
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
engine.set_overrides(config);
|
||||||
|
|
||||||
|
let cwd = std::path::Path::new(".");
|
||||||
|
let result = engine.init_dir(&cwd);
|
||||||
|
assert!(result.is_err());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue