Migrate mdbook_test_chapter_not_found to BookTest

This commit is contained in:
Eric Huss 2025-04-22 10:58:55 -07:00
parent f324aebdec
commit 909bd1c54e
2 changed files with 13 additions and 13 deletions

View file

@ -1,13 +0,0 @@
mod dummy_book;
use crate::dummy_book::DummyBook;
use mdbook::MDBook;
#[test]
fn mdbook_test_chapter_not_found() {
let temp = DummyBook::new().with_passing_test(true).build().unwrap();
let mut md = MDBook::load(temp.path()).unwrap();
assert!(md.test_chapter(vec![], Some("Bogus Chapter Name")).is_err());
}

View file

@ -74,3 +74,16 @@ fn test_individual_chapter() {
"#]]);
});
}
// Unknown chapter name.
#[test]
fn chapter_not_found() {
BookTest::from_dir("test/passing_tests").run("test -c bogus", |cmd| {
cmd.expect_failure()
.expect_stdout(str![[""]])
.expect_stderr(str![[r#"
[TIMESTAMP] [ERROR] (mdbook::utils): Error: Chapter not found: bogus
"#]]);
});
}