Extend test_store_create_delete_get()

to actually test:

1. get      -> Should return Ok(None)
2. create   -> Should return Ok(())
3. get      -> Should return Ok(Some(_))
4. delete   -> Should return Ok(())
5. get      -> Should return Ok(None)
This commit is contained in:
Matthias Beyer 2016-09-20 16:43:32 +02:00
parent 513a9bd066
commit 4f2019a20a

View file

@ -2196,28 +2196,38 @@ mod store_tests {
}
#[test]
fn test_store_create_delete_get() {
fn test_store_get_create_get_delete_get() {
let store = get_store();
for n in 1..100 {
let res = store.get(PathBuf::from(format!("test-{}", n)));
assert!(match res { Ok(None) => true, _ => false, })
}
for n in 1..100 {
let s = format!("test-{}", n);
let entry = store.create(PathBuf::from(s.clone())).unwrap();
assert!(entry.verify().is_ok());
let loc = entry.get_location().clone().into_pathbuf().unwrap();
assert!(loc.starts_with("/"));
assert!(loc.ends_with(s));
}
for n in 1..100 {
if n % 2 == 0 { continue; }
let s = format!("test-{}", n);
assert!(store.delete(PathBuf::from(s)).is_ok())
let res = store.get(PathBuf::from(format!("test-{}", n)));
assert!(match res { Ok(Some(_)) => true, _ => false, })
}
for n in 1..100 {
if n % 2 != 0 { continue; }
let s = format!("test-{}", n);
assert!(store.get(PathBuf::from(s)).is_ok())
assert!(store.delete(PathBuf::from(format!("test-{}", n))).is_ok())
}
for n in 1..100 {
let res = store.get(PathBuf::from(format!("test-{}", n)));
assert!(match res { Ok(None) => true, _ => false, })
}
}