Skip to content

Commit 82a7df4

Browse files
committed
add test: invalid field in the top level rust table in config
1 parent 313be71 commit 82a7df4

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
@@ -154,6 +154,31 @@ fn bad_config_in_book_table() {
154154
unknown field `foo`, expected one of `title`, `authors`, `description`, `src`, `language`, `text-direction`
155155
156156
157+
"#]]);
158+
});
159+
}
160+
161+
// An invalid key in the main rust table.
162+
#[test]
163+
fn bad_config_in_rust_table() {
164+
BookTest::init(|_| {})
165+
.change_file(
166+
"book.toml",
167+
"[rust]\n\
168+
title = \"bad-config\"\n",
169+
)
170+
.run("build", |cmd| {
171+
cmd.expect_failure()
172+
.expect_stdout(str![[""]])
173+
.expect_stderr(str![[r#"
174+
[TIMESTAMP] [ERROR] (mdbook_core::utils): Error: Invalid configuration file
175+
[TIMESTAMP] [ERROR] (mdbook_core::utils): [TAB]Caused By: TOML parse error at line 2, column 1
176+
|
177+
2 | title = "bad-config"
178+
| ^^^^^
179+
unknown field `title`, expected `edition`
180+
181+
157182
"#]]);
158183
});
159184
}

0 commit comments

Comments
 (0)