]> git.proxmox.com Git - rustc.git/blob - vendor/mdbook/tests/testing.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / vendor / mdbook / tests / testing.rs
1 mod dummy_book;
2
3 use crate::dummy_book::DummyBook;
4
5 use mdbook::MDBook;
6
7 #[test]
8 fn mdbook_can_correctly_test_a_passing_book() {
9 let temp = DummyBook::new().with_passing_test(true).build().unwrap();
10 let mut md = MDBook::load(temp.path()).unwrap();
11
12 let result = md.test(vec![]);
13 assert!(
14 result.is_ok(),
15 "Tests failed with {}",
16 result.err().unwrap()
17 );
18 }
19
20 #[test]
21 fn mdbook_detects_book_with_failing_tests() {
22 let temp = DummyBook::new().with_passing_test(false).build().unwrap();
23 let mut md = MDBook::load(temp.path()).unwrap();
24
25 assert!(md.test(vec![]).is_err());
26 }
27
28 #[test]
29 fn mdbook_test_chapter() {
30 let temp = DummyBook::new().with_passing_test(true).build().unwrap();
31 let mut md = MDBook::load(temp.path()).unwrap();
32
33 let result = md.test_chapter(vec![], Some("Introduction"));
34 assert!(
35 result.is_ok(),
36 "test_chapter failed with {}",
37 result.err().unwrap()
38 );
39 }
40
41 #[test]
42 fn mdbook_test_chapter_not_found() {
43 let temp = DummyBook::new().with_passing_test(true).build().unwrap();
44 let mut md = MDBook::load(temp.path()).unwrap();
45
46 assert!(md.test_chapter(vec![], Some("Bogus Chapter Name")).is_err());
47 }