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