Skip to content

Commit

Permalink
test(config): Ensure types are validated
Browse files Browse the repository at this point in the history
  • Loading branch information
Ed Page committed Apr 8, 2021
1 parent 68c0a0d commit a22567c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,8 @@ impl<'t, 'd> Default for Policy<'t, 'd> {
mod test {
use super::*;

const NEVER_EXIST_TYPE: &str = "this-type-should-never-exist-but-i-hate-you-if-it-does";

#[test]
fn test_load_config_applies_overrides() {
let storage = ConfigStorage::new();
Expand Down Expand Up @@ -390,4 +392,27 @@ mod test {
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());
}
}

0 comments on commit a22567c

Please sign in to comment.