Add some testing for the PathResolver

This commit is contained in:
Savanni D'Gerinel 2023-09-22 21:56:43 -04:00
parent d658747202
commit 163e1e1de1
1 changed files with 34 additions and 0 deletions

View File

@ -68,6 +68,18 @@ impl PathResolver {
} }
} }
impl From<String> for PathResolver {
fn from(s: String) -> Self {
Self(PathBuf::from(s))
}
}
impl From<&str> for PathResolver {
fn from(s: &str) -> Self {
Self(PathBuf::from(s.to_owned()))
}
}
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct FileId(String); pub struct FileId(String);
@ -154,3 +166,25 @@ impl App {
unimplemented!() unimplemented!()
} }
} }
#[cfg(test)]
mod test {
use super::*;
#[test]
fn paths() {
let resolver = PathResolver::from("path/82420255-d3c8-4d90-a582-f94be588c70c");
assert_eq!(
resolver.file_path(),
PathBuf::from("path/82420255-d3c8-4d90-a582-f94be588c70c")
);
assert_eq!(
resolver.metadata_path(),
PathBuf::from("path/82420255-d3c8-4d90-a582-f94be588c70c.json")
);
assert_eq!(
resolver.thumbnail_path(),
PathBuf::from("path/82420255-d3c8-4d90-a582-f94be588c70c.tn")
);
}
}