fix(config): Allow check-file to work

Looks like `deny_unknown_fields` doesn't work with `flatten`.  See serde-rs/serde#1547.

Fixes #406
This commit is contained in:
Ed Page 2022-01-24 11:53:56 -06:00
parent 9134bec15e
commit 55114b3777

View file

@ -235,7 +235,7 @@ impl TypeEngineConfig {
} }
#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[serde(deny_unknown_fields)] //#[serde(deny_unknown_fields)] // Doesn't work with `flatten`
#[serde(default)] #[serde(default)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
pub struct GlobEngineConfig { pub struct GlobEngineConfig {
@ -252,7 +252,7 @@ impl GlobEngineConfig {
} }
#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[serde(deny_unknown_fields)] //#[serde(deny_unknown_fields)] // Doesn't work with `flatten`
#[serde(default)] #[serde(default)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
pub struct EngineConfig { pub struct EngineConfig {
@ -575,6 +575,7 @@ mod test {
fn parse_extend_globs() { fn parse_extend_globs() {
let input = r#"[type.po] let input = r#"[type.po]
extend-glob = ["*.po"] extend-glob = ["*.po"]
check-file = true
"#; "#;
let mut expected = Config::default(); let mut expected = Config::default();
expected.type_.patterns.insert( expected.type_.patterns.insert(
@ -584,6 +585,7 @@ extend-glob = ["*.po"]
engine: EngineConfig { engine: EngineConfig {
tokenizer: Some(TokenizerConfig::default()), tokenizer: Some(TokenizerConfig::default()),
dict: Some(DictConfig::default()), dict: Some(DictConfig::default()),
check_file: Some(true),
..Default::default() ..Default::default()
}, },
..Default::default() ..Default::default()