Updated the test to follow our docs

This commit is contained in:
Michael-F-Bryan 2020-05-30 04:15:24 +08:00
parent 7b3e945a27
commit ebc01dbb71
No known key found for this signature in database
GPG Key ID: E9C602B0D9A998DC
1 changed files with 12 additions and 2 deletions

View File

@ -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};
@ -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;