add test: invalid table at the top level config

This commit is contained in:
Gabor Szabo
2025-08-24 09:49:43 +03:00
parent 313be7162f
commit f6c11d12e0

View File

@@ -128,6 +128,31 @@ fn bad_config_top_level() {
unknown field `foo`, expected one of `book`, `build`, `rust`, `output`, `preprocessor`
"#]]);
});
}
// An invalid table at the top level.
#[test]
fn bad_config_top_level_table() {
BookTest::init(|_| {})
.change_file(
"book.toml",
"[other]\n\
foo = 123",
)
.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 1, column 2
|
1 | [other]
| ^^^^^
unknown field `other`, expected one of `book`, `build`, `rust`, `output`, `preprocessor`
"#]]);
});
}