Skip to content

Commit 08d9fdd

Browse files
committed
Add a test for config.get deserialization error
1 parent 118c109 commit 08d9fdd

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

crates/mdbook-core/src/config.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,4 +1147,15 @@ mod tests {
11471147
assert_eq!(json!(TextDirection::RightToLeft), json!("rtl"));
11481148
assert_eq!(json!(TextDirection::LeftToRight), json!("ltr"));
11491149
}
1150+
1151+
#[test]
1152+
fn get_deserialize_error() {
1153+
let src = r#"
1154+
[preprocessor.foo]
1155+
x = 123
1156+
"#;
1157+
let cfg = Config::from_str(src).unwrap();
1158+
let err = cfg.get::<String>("preprocessor.foo.x").unwrap_err();
1159+
assert_eq!(err.to_string(), "Failed to deserialize `{name}`");
1160+
}
11501161
}

0 commit comments

Comments
 (0)