MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / test_vault_entry_crud

Function test_vault_entry_crud

atomic-core/src/pristine/txn/write/vault.rs:197–236  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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() {

Callers

nothing calls this directly

Calls 7

write_txnMethod · 0.80
put_vault_entryMethod · 0.80
commitMethod · 0.80
unwrapMethod · 0.45
pathMethod · 0.45
init_vaultMethod · 0.45
get_vault_entryMethod · 0.45

Tested by

no test coverage detected