Skip to content

Commit a40f1f2

Browse files
authored
Merge pull request #2815 from szabgab/test/invalid-field-in-rust-table
add test: invalid field in the top level rust table in config
2 parents 6c84727 + 82a7df4 commit a40f1f2

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/testsuite/config.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,31 @@ fn bad_config_in_book_table() {
179179
unknown field `foo`, expected one of `title`, `authors`, `description`, `src`, `language`, `text-direction`
180180
181181
182+
"#]]);
183+
});
184+
}
185+
186+
// An invalid key in the main rust table.
187+
#[test]
188+
fn bad_config_in_rust_table() {
189+
BookTest::init(|_| {})
190+
.change_file(
191+
"book.toml",
192+
"[rust]\n\
193+
title = \"bad-config\"\n",
194+
)
195+
.run("build", |cmd| {
196+
cmd.expect_failure()
197+
.expect_stdout(str![[""]])
198+
.expect_stderr(str![[r#"
199+
[TIMESTAMP] [ERROR] (mdbook_core::utils): Error: Invalid configuration file
200+
[TIMESTAMP] [ERROR] (mdbook_core::utils): [TAB]Caused By: TOML parse error at line 2, column 1
201+
|
202+
2 | title = "bad-config"
203+
| ^^^^^
204+
unknown field `title`, expected `edition`
205+
206+
182207
"#]]);
183208
});
184209
}

0 commit comments

Comments
 (0)