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

Function test_get_contents_basic

atomic-core/src/change/store.rs:811–840  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

809
810 #[test]
811 fn test_get_contents_basic() {
812 let store = MemoryChangeStore::new();
813 let content = b"Hello, World!";
814 let change = create_test_change("Content test", content);
815 let hash = change.hash().unwrap();
816 store.insert(hash, change);
817
818 // Create a mock hash function
819 let node_id = NodeId::new(1);
820 let hash_fn = move |id: NodeId| {
821 if id == node_id {
822 Some(hash)
823 } else {
824 None
825 }
826 };
827
828 // Read the full content
829 let node = GraphNode::new(
830 node_id,
831 ChangePosition::new(0),
832 ChangePosition::new(content.len() as u64),
833 );
834 let mut buf = vec![0u8; content.len()];
835
836 let n = store.get_contents(hash_fn, node, &mut buf).unwrap();
837
838 assert_eq!(n, content.len());
839 assert_eq!(&buf, content);
840 }
841
842 #[test]
843 fn test_get_contents_partial() {

Callers

nothing calls this directly

Calls 6

create_test_changeFunction · 0.70
unwrapMethod · 0.45
hashMethod · 0.45
insertMethod · 0.45
lenMethod · 0.45
get_contentsMethod · 0.45

Tested by

no test coverage detected