Merge pull request #2814 from szabgab/test/invalid-table-at-top-level

add test: invalid table at the top level config
This commit is contained in:
Eric Huss 2025-08-25 16:46:42 +00:00 committed by GitHub
commit 6c847275c5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -128,6 +128,31 @@ fn bad_config_top_level() {
unknown field `foo`, expected one of `book`, `build`, `rust`, `output`, `preprocessor` 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`
"#]]); "#]]);
}); });
} }