Skip to content

Commit c29f628

Browse files
committed
add test for overallocation in chunker
License: MIT Signed-off-by: Steven Allen <[email protected]>
1 parent 414b0ff commit c29f628

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

importer/chunk/splitting_test.go

+14
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,20 @@ func copyBuf(buf []byte) []byte {
2222
return cpy
2323
}
2424

25+
func TestSizeSplitterOverAllocate(t *testing.T) {
26+
max := 1000
27+
r := bytes.NewReader(randBuf(t, max))
28+
chunksize := int64(1024 * 256)
29+
splitter := NewSizeSplitter(r, chunksize)
30+
chunk, err := splitter.NextBytes()
31+
if err != nil {
32+
t.Fatal(err)
33+
}
34+
if cap(chunk) > len(chunk) {
35+
t.Fatal("chunk capacity too large")
36+
}
37+
}
38+
2539
func TestSizeSplitterIsDeterministic(t *testing.T) {
2640
if testing.Short() {
2741
t.SkipNow()

0 commit comments

Comments
 (0)