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

Function test_get_contents_partial

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

Source from the content-addressed store, hash-verified

817
818 #[test]
819 fn test_get_contents_partial() {
820 let store = MemoryChangeStore::new();
821 let content = b"0123456789";
822 let change = create_test_change("Partial", content);
823 let hash = change.hash().unwrap();
824 store.insert(hash, change);
825
826 let node_id = NodeId::new(1);
827 let hash_fn = move |id: NodeId| {
828 if id == node_id {
829 Some(hash)
830 } else {
831 None
832 }
833 };
834
835 // Read middle portion
836 let node = GraphNode::new(node_id, ChangePosition::new(3), ChangePosition::new(7));
837 let mut buf = vec![0u8; 4];
838
839 let n = store.get_contents(hash_fn, node, &mut buf).unwrap();
840
841 assert_eq!(n, 4);
842 assert_eq!(&buf, b"3456");
843 }
844
845 #[test]
846 fn test_get_contents_empty_vertex() {

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected