add test: invalid field in the top level rust table in config

This commit is contained in:
Gabor Szabo
2025-08-24 09:54:59 +03:00
parent 313be7162f
commit 82a7df41a6

View File

@@ -154,6 +154,31 @@ fn bad_config_in_book_table() {
unknown field `foo`, expected one of `title`, `authors`, `description`, `src`, `language`, `text-direction`
"#]]);
});
}
// An invalid key in the main rust table.
#[test]
fn bad_config_in_rust_table() {
BookTest::init(|_| {})
.change_file(
"book.toml",
"[rust]\n\
title = \"bad-config\"\n",
)
.run("build", |cmd| {
cmd.expect_failure()
.expect_stdout(str![[""]])
.expect_stderr(str![[r#"
[TIMESTAMP] [ERROR] (mdbook_core::utils): Error: Invalid configuration file
[TIMESTAMP] [ERROR] (mdbook_core::utils): [TAB]Caused By: TOML parse error at line 2, column 1
|
2 | title = "bad-config"
| ^^^^^
unknown field `title`, expected `edition`
"#]]);
});
}