Add test for a chapter with no source path
This commit is contained in:
parent
132ca0dca3
commit
53c3a92285
1 changed files with 21 additions and 1 deletions
|
|
@ -3,10 +3,11 @@ mod dummy_book;
|
|||
use crate::dummy_book::{assert_contains_strings, assert_doesnt_contain_strings, DummyBook};
|
||||
|
||||
use anyhow::Context;
|
||||
use mdbook::book::Chapter;
|
||||
use mdbook::config::Config;
|
||||
use mdbook::errors::*;
|
||||
use mdbook::utils::fs::write_file;
|
||||
use mdbook::MDBook;
|
||||
use mdbook::{BookItem, MDBook};
|
||||
use pretty_assertions::assert_eq;
|
||||
use select::document::Document;
|
||||
use select::predicate::{Attr, Class, Name, Predicate};
|
||||
|
|
@ -1031,3 +1032,22 @@ fn custom_header_attributes() {
|
|||
];
|
||||
assert_contains_strings(&contents, summary_strings);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn with_no_source_path() {
|
||||
// Test for a regression where search would fail if source_path is None.
|
||||
let temp = DummyBook::new().build().unwrap();
|
||||
let mut md = MDBook::load(temp.path()).unwrap();
|
||||
let chapter = Chapter {
|
||||
name: "Sample chapter".to_string(),
|
||||
content: "".to_string(),
|
||||
number: None,
|
||||
sub_items: Vec::new(),
|
||||
path: Some(PathBuf::from("sample.html")),
|
||||
source_path: None,
|
||||
parent_names: Vec::new(),
|
||||
};
|
||||
md.book.sections.push(BookItem::Chapter(chapter));
|
||||
md.build().unwrap();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue