Helper: write a full change file with all section types.
()
| 130 | |
| 131 | /// Helper: write a full change file with all section types. |
| 132 | fn write_full_change() -> (Vec<u8>, [u8; 32]) { |
| 133 | let mut buf = Vec::new(); |
| 134 | let self_hash = *blake3::hash(b"full").as_bytes(); |
| 135 | let dep_hash = *blake3::hash(b"dep1").as_bytes(); |
| 136 | |
| 137 | let mut hash_table = HashDedupTable::new(self_hash); |
| 138 | let dep_idx = hash_table.insert(dep_hash).unwrap(); |
| 139 | |
| 140 | let file_header = FileHeader::builder() |
| 141 | .hash_table_entries(hash_table.len() as u32) |
| 142 | .graph_section_count(2) |
| 143 | .semantic_section_count(2) |
| 144 | .contents_chunks(3) |
| 145 | .with_provenance() |
| 146 | .with_unhashed() |
| 147 | .build(); |
| 148 | |
| 149 | let mut writer = ChangeWriter::new(&mut buf, WriterOptions::default()); |
| 150 | writer.write_file_header(&file_header).unwrap(); |
| 151 | writer.write_hash_table(&hash_table).unwrap(); |
| 152 | writer |
| 153 | .write_change_header(&ChangeHeader::new("Full change")) |
| 154 | .unwrap(); |
| 155 | writer.write_dependencies(&[dep_idx]).unwrap(); |
| 156 | writer.write_provenance(&[]).unwrap(); |
| 157 | writer |
| 158 | .write_graph_section(b"graph data for file_a.rs") |
| 159 | .unwrap(); |
| 160 | writer |
| 161 | .write_graph_section(b"graph data for file_b.rs") |
| 162 | .unwrap(); |
| 163 | writer |
| 164 | .write_semantic_section(b"semantic data for file_a.rs") |
| 165 | .unwrap(); |
| 166 | writer |
| 167 | .write_semantic_section(b"semantic data for file_b.rs") |
| 168 | .unwrap(); |
| 169 | writer |
| 170 | .write_content_chunk(0, b"chunk zero content bytes") |
| 171 | .unwrap(); |
| 172 | writer |
| 173 | .write_content_chunk(1, b"chunk one content bytes") |
| 174 | .unwrap(); |
| 175 | writer |
| 176 | .write_content_chunk(2, b"chunk two content bytes") |
| 177 | .unwrap(); |
| 178 | writer |
| 179 | .write_unhashed(b"{\"transcript\": \"AI reasoning\"}") |
| 180 | .unwrap(); |
| 181 | let outcome = writer.finalize().unwrap(); |
| 182 | |
| 183 | (buf, outcome.content_hash) |
| 184 | } |
| 185 | |
| 186 | // ── Opening ──────────────────────────────────────────────────── |
| 187 |
no test coverage detected