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

Function test_register_change

atomic-core/src/pristine/txn/write/tests.rs:28–46  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26
27 #[test]
28 fn test_register_change() {
29 let dir = tempdir().unwrap();
30 let db_path = dir.path().join("pristine");
31 let pristine = Pristine::open(&db_path).unwrap();
32
33 let mut txn = pristine.write_txn().unwrap();
34 let hash = Hash::of(b"test change");
35 let id = txn.register_change(&hash).unwrap();
36
37 // Should get same ID for same hash
38 let id2 = txn.register_change(&hash).unwrap();
39 assert_eq!(id, id2);
40
41 // Should be able to look up both ways
42 assert_eq!(txn.get_external(id).unwrap(), Some(hash));
43 assert_eq!(txn.get_internal(&hash).unwrap(), Some(id));
44
45 txn.commit().unwrap();
46 }
47
48 #[test]
49 fn abort_only_preview_does_not_consume_ids_or_commit() {

Callers

nothing calls this directly

Calls 6

openFunction · 0.85
write_txnMethod · 0.80
register_changeMethod · 0.80
unwrapMethod · 0.45
pathMethod · 0.45
commitMethod · 0.45

Tested by

no test coverage detected