From 8f704844c3a425579ade024977815db07def2994 Mon Sep 17 00:00:00 2001 From: Jeff Baskin Date: Sat, 3 Dec 2022 09:15:58 -0500 Subject: [PATCH] added add_cache function. --- src/morethantext/mod.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/morethantext/mod.rs b/src/morethantext/mod.rs index 117b0cb..be947db 100644 --- a/src/morethantext/mod.rs +++ b/src/morethantext/mod.rs @@ -5,6 +5,10 @@ use error::DBError; const DATA: &str = "data"; +enum CacheEntry { + Raw(String), +} + #[derive(Clone)] pub struct MoreThanText; @@ -23,6 +27,10 @@ impl MoreThanText { } Ok(Self {}) } + + async fn add_entry(&self, _entry: CacheEntry) -> String { + "fred".to_string() + } } #[cfg(test)] @@ -64,3 +72,19 @@ mod init { }; } } + +#[cfg(test)] +mod cache { + use super::*; + use tempfile::tempdir; + + #[async_std::test] + async fn add_entry() { + let dir = tempdir().unwrap(); + let db = MoreThanText::new(dir.path().to_str().unwrap()).await.unwrap(); + let data = CacheEntry::Raw("something".to_string()); + db.add_entry(data).await; + drop(db); + dir.close().unwrap(); + } +}