()
| 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() { |
nothing calls this directly
no test coverage detected