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

Function test_register_change

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

Source from the content-addressed store, hash-verified

10
11 #[test]
12 fn test_register_change() {
13 let dir = tempdir().unwrap();
14 let db_path = dir.path().join("pristine");
15 let pristine = Pristine::open(&db_path).unwrap();
16
17 let mut txn = pristine.write_txn().unwrap();
18 let hash = Hash::of(b"test change");
19 let id = txn.register_change(&hash).unwrap();
20
21 // Should get same ID for same hash
22 let id2 = txn.register_change(&hash).unwrap();
23 assert_eq!(id, id2);
24
25 // Should be able to look up both ways
26 assert_eq!(txn.get_external(id).unwrap(), Some(hash));
27 assert_eq!(txn.get_internal(&hash).unwrap(), Some(id));
28
29 txn.commit().unwrap();
30 }
31
32 #[test]
33 fn test_view_operations() {

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected