()
| 195 | |
| 196 | #[test] |
| 197 | fn test_vault_entry_crud() { |
| 198 | let dir = tempdir().unwrap(); |
| 199 | let pristine = Pristine::open(dir.path().join("db")).unwrap(); |
| 200 | |
| 201 | let mut txn = pristine.write_txn().unwrap(); |
| 202 | txn.init_vault().unwrap(); |
| 203 | |
| 204 | let entry = VaultEntry::new( |
| 205 | VaultEntryType::Memory, |
| 206 | b"# Architecture\nWe use crates.".to_vec(), |
| 207 | r#"{"name":"architecture"}"#.to_string(), |
| 208 | "2025-07-15T12:00:00Z".to_string(), |
| 209 | ); |
| 210 | |
| 211 | // Store |
| 212 | txn.put_vault_entry("memory/architecture.md", &entry) |
| 213 | .unwrap(); |
| 214 | |
| 215 | // Retrieve |
| 216 | let retrieved = txn |
| 217 | .get_vault_entry("memory/architecture.md") |
| 218 | .unwrap() |
| 219 | .unwrap(); |
| 220 | assert_eq!(retrieved.entry_type, VaultEntryType::Memory); |
| 221 | assert_eq!(retrieved.content_bytes, entry.content_bytes); |
| 222 | assert_eq!(retrieved.content_hash, entry.content_hash); |
| 223 | |
| 224 | // Not found |
| 225 | assert!(txn.get_vault_entry("nonexistent").unwrap().is_none()); |
| 226 | |
| 227 | // Delete |
| 228 | assert!(txn.del_vault_entry("memory/architecture.md").unwrap()); |
| 229 | assert!(!txn.del_vault_entry("memory/architecture.md").unwrap()); |
| 230 | assert!(txn |
| 231 | .get_vault_entry("memory/architecture.md") |
| 232 | .unwrap() |
| 233 | .is_none()); |
| 234 | |
| 235 | txn.commit().unwrap(); |
| 236 | } |
| 237 | |
| 238 | #[test] |
| 239 | fn test_vault_list_entries() { |
nothing calls this directly
no test coverage detected