@@ -3,10 +3,11 @@ mod dummy_book;
3
3
use crate :: dummy_book:: { assert_contains_strings, assert_doesnt_contain_strings, DummyBook } ;
4
4
5
5
use anyhow:: Context ;
6
+ use mdbook:: book:: Chapter ;
6
7
use mdbook:: config:: Config ;
7
8
use mdbook:: errors:: * ;
8
9
use mdbook:: utils:: fs:: write_file;
9
- use mdbook:: MDBook ;
10
+ use mdbook:: { BookItem , MDBook } ;
10
11
use pretty_assertions:: assert_eq;
11
12
use select:: document:: Document ;
12
13
use select:: predicate:: { Attr , Class , Name , Predicate } ;
@@ -1031,3 +1032,22 @@ fn custom_header_attributes() {
1031
1032
] ;
1032
1033
assert_contains_strings ( & contents, summary_strings) ;
1033
1034
}
1035
+
1036
+ #[ test]
1037
+ #[ should_panic]
1038
+ fn with_no_source_path ( ) {
1039
+ // Test for a regression where search would fail if source_path is None.
1040
+ let temp = DummyBook :: new ( ) . build ( ) . unwrap ( ) ;
1041
+ let mut md = MDBook :: load ( temp. path ( ) ) . unwrap ( ) ;
1042
+ let chapter = Chapter {
1043
+ name : "Sample chapter" . to_string ( ) ,
1044
+ content : "" . to_string ( ) ,
1045
+ number : None ,
1046
+ sub_items : Vec :: new ( ) ,
1047
+ path : Some ( PathBuf :: from ( "sample.html" ) ) ,
1048
+ source_path : None ,
1049
+ parent_names : Vec :: new ( ) ,
1050
+ } ;
1051
+ md. book . sections . push ( BookItem :: Chapter ( chapter) ) ;
1052
+ md. build ( ) . unwrap ( ) ;
1053
+ }
0 commit comments