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

Function test_get_contents_partial

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

Source from the content-addressed store, hash-verified

841
842 #[test]
843 fn test_get_contents_partial() {
844 let store = MemoryChangeStore::new();
845 let content = b"0123456789";
846 let change = create_test_change("Partial", content);
847 let hash = change.hash().unwrap();
848 store.insert(hash, change);
849
850 let node_id = NodeId::new(1);
851 let hash_fn = move |id: NodeId| {
852 if id == node_id {
853 Some(hash)
854 } else {
855 None
856 }
857 };
858
859 // Read middle portion
860 let node = GraphNode::new(node_id, ChangePosition::new(3), ChangePosition::new(7));
861 let mut buf = vec![0u8; 4];
862
863 let n = store.get_contents(hash_fn, node, &mut buf).unwrap();
864
865 assert_eq!(n, 4);
866 assert_eq!(&buf, b"3456");
867 }
868
869 #[test]
870 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