Migrate chapter_settings_validation_error to BookTest
This commit is contained in:
parent
2056c87e28
commit
0b577ebd76
4 changed files with 19 additions and 25 deletions
|
|
@ -375,31 +375,6 @@ fn failure_on_missing_theme_directory() {
|
||||||
assert!(got.is_err());
|
assert!(got.is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "search")]
|
|
||||||
mod search {
|
|
||||||
use crate::dummy_book::DummyBook;
|
|
||||||
use mdbook::utils::fs::write_file;
|
|
||||||
use mdbook::MDBook;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn chapter_settings_validation_error() {
|
|
||||||
let temp = DummyBook::new().build().unwrap();
|
|
||||||
let book_toml = r#"
|
|
||||||
[book]
|
|
||||||
title = "Search Test"
|
|
||||||
|
|
||||||
[output.html.search.chapter]
|
|
||||||
"does-not-exist" = { enable = false }
|
|
||||||
"#;
|
|
||||||
write_file(temp.path(), "book.toml", book_toml.as_bytes()).unwrap();
|
|
||||||
let md = MDBook::load(temp.path()).unwrap();
|
|
||||||
let err = md.build().unwrap_err();
|
|
||||||
assert!(format!("{err:?}").contains(
|
|
||||||
"[output.html.search.chapter] key `does-not-exist` does not match any chapter paths"
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn custom_fonts() {
|
fn custom_fonts() {
|
||||||
// Tests to ensure custom fonts are copied as expected.
|
// Tests to ensure custom fonts are copied as expected.
|
||||||
|
|
|
||||||
|
|
@ -125,3 +125,17 @@ fn with_no_source_path() {
|
||||||
book.book.sections.push(BookItem::Chapter(chapter));
|
book.book.sections.push(BookItem::Chapter(chapter));
|
||||||
book.build().unwrap();
|
book.build().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Checks that invalid settings in search chapter is rejected.
|
||||||
|
#[test]
|
||||||
|
fn chapter_settings_validation_error() {
|
||||||
|
BookTest::from_dir("search/chapter_settings_validation_error").run("build", |cmd| {
|
||||||
|
cmd.expect_failure().expect_stderr(str![[r#"
|
||||||
|
[TIMESTAMP] [INFO] (mdbook::book): Book building has started
|
||||||
|
[TIMESTAMP] [INFO] (mdbook::book): Running the html backend
|
||||||
|
[TIMESTAMP] [ERROR] (mdbook::utils): Error: Rendering failed
|
||||||
|
[TIMESTAMP] [ERROR] (mdbook::utils): [TAB]Caused By: [output.html.search.chapter] key `does-not-exist` does not match any chapter paths
|
||||||
|
|
||||||
|
"#]]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
[book]
|
||||||
|
title = "Search Test"
|
||||||
|
|
||||||
|
[output.html.search.chapter]
|
||||||
|
"does-not-exist" = { enable = false }
|
||||||
Loading…
Add table
Reference in a new issue