Size chunk range storage to the emitted windows

This commit is contained in:
2026-11-26 05:16:56 +00:00
parent b0210db974
commit f31b0f30a2
3 changed files with 39 additions and 3 deletions

View File

@@ -110,6 +110,28 @@ func TestPlanMaximumUnitCount(t *testing.T) {
}
}
func TestPlanHighOverlapStopsAtSourceEnd(t *testing.T) {
for _, test := range []struct {
name string
units int
max int
overlap int
want []source.ChunkRange
}{
{"one complete range", 40, 40, 39, []source.ChunkRange{{StartUnitID: 1, EndUnitID: 40}}},
{"exact remaining step", 5, 4, 3, []source.ChunkRange{{StartUnitID: 1, EndUnitID: 4}, {StartUnitID: 2, EndUnitID: 5}}},
{"partial remaining step", 7, 4, 2, []source.ChunkRange{{StartUnitID: 1, EndUnitID: 4}, {StartUnitID: 3, EndUnitID: 6}, {StartUnitID: 5, EndUnitID: 7}}},
} {
t.Run(test.name, func(t *testing.T) {
chunker := newChunker(t, map[string]any{"max_units": test.max, "overlap_units": test.overlap})
result, err := runChunk(context.Background(), chunker, contracts.ChunkInput{Source: testSource(test.units)})
if err != nil || !reflect.DeepEqual(result.Value.Ranges, test.want) {
t.Fatalf("ranges = %#v, %v; want %#v", result.Value.Ranges, err, test.want)
}
})
}
}
func TestPlanRejectsInvalidOptions(t *testing.T) {
tests := []struct {
name string