Fix tests
This commit is contained in:
parent
6f832ed434
commit
7fd73f6ff7
|
@ -662,9 +662,10 @@ mod tests {
|
|||
let got = determine_preprocessors(&cfg);
|
||||
|
||||
assert!(got.is_ok());
|
||||
assert_eq!(got.as_ref().unwrap().len(), 2);
|
||||
assert_eq!(got.as_ref().unwrap()[0].name(), "index");
|
||||
assert_eq!(got.as_ref().unwrap()[1].name(), "links");
|
||||
assert_eq!(got.as_ref().unwrap().len(), 3);
|
||||
assert_eq!(got.as_ref().unwrap()[0].name(), "drinks");
|
||||
assert_eq!(got.as_ref().unwrap()[1].name(), "index");
|
||||
assert_eq!(got.as_ref().unwrap()[2].name(), "links");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -56,17 +56,19 @@ impl Preprocessor for DrinkPreprocessor {
|
|||
fn run(&self, ctx: &PreprocessorContext, mut book: Book) -> Result<Book> {
|
||||
let path = ctx.root.join("drinks.txt");
|
||||
|
||||
let drinks: Dict = {
|
||||
let reader = BufReader::new(File::open(path).expect("Cannot open drinks dictionary"));
|
||||
reader
|
||||
.lines()
|
||||
.filter_map(|l| {
|
||||
l.expect("Cannot read line in drinks dictionary")
|
||||
.split_once(SPLITTER)
|
||||
.map(|(name, value)| (name.trim().to_owned(), value.trim().to_owned()))
|
||||
})
|
||||
.collect::<HashMap<_, _>>()
|
||||
};
|
||||
if !path.exists() {
|
||||
return Ok(book);
|
||||
}
|
||||
|
||||
let reader = BufReader::new(File::open(path).expect("Cannot open drinks dictionary"));
|
||||
let drinks: Dict = reader
|
||||
.lines()
|
||||
.filter_map(|l| {
|
||||
l.expect("Cannot read line in drinks dictionary")
|
||||
.split_once(SPLITTER)
|
||||
.map(|(name, value)| (name.trim().to_owned(), value.trim().to_owned()))
|
||||
})
|
||||
.collect::<HashMap<_, _>>();
|
||||
|
||||
book.for_each_mut(|section: &mut BookItem| {
|
||||
if let BookItem::Chapter(ref mut ch) = *section {
|
||||
|
|
Loading…
Reference in New Issue