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

Function test_get_contents_basic

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

Source from the content-addressed store, hash-verified

785
786 #[test]
787 fn test_get_contents_basic() {
788 let store = MemoryChangeStore::new();
789 let content = b"Hello, World!";
790 let change = create_test_change("Content test", content);
791 let hash = change.hash().unwrap();
792 store.insert(hash, change);
793
794 // Create a mock hash function
795 let node_id = NodeId::new(1);
796 let hash_fn = move |id: NodeId| {
797 if id == node_id {
798 Some(hash)
799 } else {
800 None
801 }
802 };
803
804 // Read the full content
805 let node = GraphNode::new(
806 node_id,
807 ChangePosition::new(0),
808 ChangePosition::new(content.len() as u64),
809 );
810 let mut buf = vec![0u8; content.len()];
811
812 let n = store.get_contents(hash_fn, node, &mut buf).unwrap();
813
814 assert_eq!(n, content.len());
815 assert_eq!(&buf, content);
816 }
817
818 #[test]
819 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