tests: add some rm (#10)

Ref: #3
This commit is contained in:
ricky 2019-10-17 18:09:41 -04:00 committed by Kat Marchán
parent d2157ac9d8
commit 42f4e1da63
1 changed files with 33 additions and 0 deletions

View File

@ -30,3 +30,36 @@ pub fn all<P: AsRef<Path>>(cache: P) -> Result<(), Error> {
}
Ok(())
}
#[cfg(test)]
mod tests {
#[test]
fn all() {
let tmp = tempfile::tempdir().unwrap();
let dir = tmp.path().to_owned();
let sri = crate::put::data(&dir, "key", b"my-data").unwrap();
crate::rm::all(&dir).unwrap();
let new_entry = crate::get::info(&dir, "key").unwrap();
assert_eq!(new_entry, None);
let data_exists = crate::get::hash_exists(&dir, &sri);
assert_eq!(data_exists, false);
}
#[test]
fn entry() {
let tmp = tempfile::tempdir().unwrap();
let dir = tmp.path().to_owned();
let sri = crate::put::data(&dir, "key", b"my-data").unwrap();
crate::rm::entry(&dir, "key").unwrap();
let new_entry = crate::get::info(&dir, "key").unwrap();
assert_eq!(new_entry, None);
let data_exists = crate::get::hash_exists(&dir, &sri);
assert_eq!(data_exists, true);
}
}