mirror of
https://github.com/orhun/systeroid
synced 2024-07-21 10:25:00 +00:00
test(cache): add tests for cache module
This commit is contained in:
parent
cf151b4108
commit
41ca625e99
|
@ -81,3 +81,23 @@ impl Cache {
|
|||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::env;
|
||||
|
||||
#[test]
|
||||
fn test_cache() -> Result<()> {
|
||||
let cache = Cache::init()?;
|
||||
let data = String::from("cache_test");
|
||||
let cache_data = CacheData::new(
|
||||
&data,
|
||||
&Path::new(env!("CARGO_MANIFEST_DIR")).join("Cargo.toml"),
|
||||
)?;
|
||||
cache.write(cache_data, "data")?;
|
||||
assert!(cache.exists("data"));
|
||||
assert_eq!(data, cache.read::<String>("data")?.data);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue