fix test and formatting

This commit is contained in:
Manuel Woelker 2020-06-10 15:33:09 +02:00
parent 406b325c54
commit d7df832cce
3 changed files with 7 additions and 10 deletions

View File

@ -83,7 +83,7 @@ pub fn execute(args: &ArgMatches) -> Result<()> {
.config .config
.get("output.html.input-404") .get("output.html.input-404")
.map(toml::Value::as_str) .map(toml::Value::as_str)
.flatten() .and_then(std::convert::identity) // flatten
.map(ToString::to_string); .map(ToString::to_string);
let file_404 = get_404_output_file(&input_404); let file_404 = get_404_output_file(&input_404);

View File

@ -1022,10 +1022,7 @@ mod tests {
let got = Config::from_str(src).unwrap(); let got = Config::from_str(src).unwrap();
let html_config = got.html_config().unwrap(); let html_config = got.html_config().unwrap();
assert_eq!(html_config.input_404, None); assert_eq!(html_config.input_404, None);
assert_eq!( assert_eq!(&get_404_output_file(&html_config.input_404), "404.html");
&get_404_output_file(&html_config.input_404),
"404.html"
);
} }
#[test] #[test]
@ -1039,9 +1036,6 @@ mod tests {
let got = Config::from_str(src).unwrap(); let got = Config::from_str(src).unwrap();
let html_config = got.html_config().unwrap(); let html_config = got.html_config().unwrap();
assert_eq!(html_config.input_404, Some("missing.md".to_string())); assert_eq!(html_config.input_404, Some("missing.md".to_string()));
assert_eq!( assert_eq!(&get_404_output_file(&html_config.input_404), "missing.html");
&get_404_output_file(&html_config.input_404),
"missing.html"
);
} }
} }

View File

@ -178,7 +178,10 @@ pub fn copy_files_except_ext(
} }
pub fn get_404_output_file(input_404: &Option<String>) -> String { pub fn get_404_output_file(input_404: &Option<String>) -> String {
input_404.as_ref().unwrap_or(&"404.md".to_string()).replace(".md", ".html") input_404
.as_ref()
.unwrap_or(&"404.md".to_string())
.replace(".md", ".html")
} }
#[cfg(test)] #[cfg(test)]