#[test]
fn test_new_file_unlocked_by_default() -> anyhow::Result<()> {
let cache = fcache::new()?;
let cache_file = cache.get("file.txt", |_| Ok(()))?;
assert!(!cache_file.is_locked(), "File should be initially unlocked");
assert!(cache_file.is_unlocked(), "File should be initially unlocked");
Ok(())
}
#[test]
fn test_file_locking() -> anyhow::Result<()> {
let cache = fcache::new()?;
let mut cache_file = cache.get("file.txt", |_| Ok(()))?;
cache_file.lock()?;
assert!(cache_file.is_locked(), "File should be locked");
assert!(!cache_file.is_unlocked(), "File should be locked");
cache_file.unlock()?;
assert!(!cache_file.is_locked(), "File should be unlocked");
assert!(cache_file.is_unlocked(), "File should be unlocked");
Ok(())
}