Skip to content

Commit

Permalink
Updated the test to follow our docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-F-Bryan committed May 29, 2020
1 parent 7b3e945 commit ebc01db
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions tests/rendered_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::collections::HashMap;
use std::ffi::OsStr;
use std::fs;
use std::io::Write;
use std::path::{Path, PathBuf};
use std::path::{Component, Path, PathBuf};
use tempfile::Builder as TempFileBuilder;
use walkdir::{DirEntry, WalkDir};

Expand Down Expand Up @@ -532,12 +532,22 @@ fn redirects_are_emitted_correctly() {
md.build().unwrap();

for (original, redirect) in &redirects {
let redirect_file = md.build_dir_for("html").join(original);
let mut redirect_file = md.build_dir_for("html");
// append everything except the bits that make it absolute
// (e.g. "/" or "C:\")
redirect_file.extend(remove_absolute_components(&original));
let contents = fs::read_to_string(&redirect_file).unwrap();
assert!(contents.contains(redirect));
}
}

fn remove_absolute_components(path: &Path) -> impl Iterator<Item = Component> + '_ {
path.components().skip_while(|c| match c {
Component::Prefix(_) | Component::RootDir => true,
_ => false,
})
}

#[cfg(feature = "search")]
mod search {
use crate::dummy_book::DummyBook;
Expand Down

0 comments on commit ebc01db

Please sign in to comment.