From 163e1e1de148588719fc82abbcaa3f9504d33e82 Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Fri, 22 Sep 2023 21:56:43 -0400 Subject: [PATCH] Add some testing for the PathResolver --- file-service/src/lib/mod.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/file-service/src/lib/mod.rs b/file-service/src/lib/mod.rs index 99b2f5b..8bcd48a 100644 --- a/file-service/src/lib/mod.rs +++ b/file-service/src/lib/mod.rs @@ -68,6 +68,18 @@ impl PathResolver { } } +impl From 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)] pub struct FileId(String); @@ -154,3 +166,25 @@ impl App { 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") + ); + } +}