Merge pull request #2815 from szabgab/test/invalid-field-in-rust-table

add test: invalid field in the top level rust table in config
This commit is contained in:
Eric Huss
2025-08-25 16:47:08 +00:00
committed by GitHub

View File

@@ -179,6 +179,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`
"#]]);
});
}