added add_cache function.
This commit is contained in:
		@@ -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();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user