2017-11-16 15:51:12 +08:00
|
|
|
mod dummy_book;
|
2017-09-02 07:40:39 +08:00
|
|
|
|
2019-05-26 02:50:41 +08:00
|
|
|
use crate::dummy_book::DummyBook;
|
2018-01-17 06:13:47 +08:00
|
|
|
|
2018-07-24 01:45:01 +08:00
|
|
|
use mdbook::MDBook;
|
2017-07-10 18:17:19 +08:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn mdbook_can_correctly_test_a_passing_book() {
|
2017-11-16 15:51:12 +08:00
|
|
|
let temp = DummyBook::new().with_passing_test(true).build().unwrap();
|
2017-11-18 20:41:04 +08:00
|
|
|
let mut md = MDBook::load(temp.path()).unwrap();
|
2017-07-10 18:17:19 +08:00
|
|
|
|
2019-08-07 10:11:36 +08:00
|
|
|
let result = md.test(vec![]);
|
|
|
|
assert!(
|
|
|
|
result.is_ok(),
|
|
|
|
"Tests failed with {}",
|
|
|
|
result.err().unwrap()
|
|
|
|
);
|
2017-07-10 18:17:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn mdbook_detects_book_with_failing_tests() {
|
2017-11-16 15:51:12 +08:00
|
|
|
let temp = DummyBook::new().with_passing_test(false).build().unwrap();
|
2018-07-26 01:17:17 +08:00
|
|
|
let mut md = MDBook::load(temp.path()).unwrap();
|
2017-07-10 18:17:19 +08:00
|
|
|
|
|
|
|
assert!(md.test(vec![]).is_err());
|
2017-09-02 07:40:39 +08:00
|
|
|
}
|
2022-08-26 10:13:51 +08:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn mdbook_test_chapter() {
|
|
|
|
let temp = DummyBook::new().with_passing_test(true).build().unwrap();
|
|
|
|
let mut md = MDBook::load(temp.path()).unwrap();
|
|
|
|
|
|
|
|
let result = md.test_chapter(vec![], Some("Introduction"));
|
|
|
|
assert!(
|
|
|
|
result.is_ok(),
|
|
|
|
"test_chapter failed with {}",
|
|
|
|
result.err().unwrap()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[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());
|
|
|
|
}
|