diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2018-07-11 21:52:39 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2018-07-11 21:59:53 +0100 |
commit | 88160e5d244e241537b78bf0bc8f2f9199f068d5 (patch) | |
tree | ce9df3db270031d723bdb9a6f23ead97b8470858 | |
parent | f74d121b8e6d87bf27c07b3d53c171000fc74f4e (diff) | |
download | askama-88160e5d244e241537b78bf0bc8f2f9199f068d5.tar.gz askama-88160e5d244e241537b78bf0bc8f2f9199f068d5.tar.bz2 askama-88160e5d244e241537b78bf0bc8f2f9199f068d5.zip |
Revert to using assert_eq!() for path tests
Diffstat (limited to '')
-rw-r--r-- | askama_shared/src/path.rs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/askama_shared/src/path.rs b/askama_shared/src/path.rs index eff8f29..43f8fdf 100644 --- a/askama_shared/src/path.rs +++ b/askama_shared/src/path.rs @@ -37,6 +37,16 @@ pub fn find_template_from_path(path: &str, start_at: Option<&Path>) -> PathBuf { #[cfg(test)] mod tests { use super::{find_template_from_path, get_template_source}; + use std::env; + use std::path::{Path, PathBuf}; + + fn assert_eq_rooted(actual: &Path, expected: &str) { + let mut root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); + root.push("templates"); + let mut inner = PathBuf::new(); + inner.push(expected); + assert_eq!(actual.strip_prefix(root).unwrap(), inner); + } #[test] fn get_source() { @@ -48,7 +58,7 @@ mod tests { fn find_absolute() { let root = find_template_from_path("a.html", None); let path = find_template_from_path("sub/b.html", Some(&root)); - assert!(path.to_str().unwrap().ends_with("sub/b.html")); + assert_eq_rooted(&path, "sub/b.html"); } #[test] @@ -62,13 +72,13 @@ mod tests { fn find_relative() { let root = find_template_from_path("sub/b.html", None); let path = find_template_from_path("c.html", Some(&root)); - assert!(path.to_str().unwrap().ends_with("sub/c.html")); + assert_eq_rooted(&path, "sub/c.html"); } #[test] fn find_relative_sub() { let root = find_template_from_path("sub/b.html", None); let path = find_template_from_path("sub1/d.html", Some(&root)); - assert!(path.to_str().unwrap().ends_with("sub/sub1/d.html")); + assert_eq_rooted(&path, "sub/sub1/d.html"); } } |