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