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