Skip to content

Commit

Permalink
Change chunker test source (#959)
Browse files Browse the repository at this point in the history
* Change chunker test source

* Emit chunk if the size isn't 0
  • Loading branch information
bill-rich committed Dec 6, 2022
1 parent 9f99ee4 commit 1a1c2e2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
4 changes: 3 additions & 1 deletion pkg/sources/chunker.go
Expand Up @@ -37,7 +37,9 @@ func Chunker(originalChunk *Chunk) chan *Chunk {
}
peekData, _ := reader.Peek(PeekSize)
chunk.Data = append(chunkBytes[:n], peekData...)
chunkChan <- &chunk
if n > 0 {
chunkChan <- &chunk
}
if errors.Is(err, io.EOF) {
break
}
Expand Down
9 changes: 2 additions & 7 deletions pkg/sources/chunker_test.go
Expand Up @@ -5,19 +5,14 @@ import (
"bytes"
"errors"
"io"
"net/http"
"testing"

diskbufferreader "github.com/bill-rich/disk-buffer-reader"
)

func TestChunker(t *testing.T) {
resp, err := http.Get("https://raw.githubusercontent.com/bill-rich/bad-secrets/master/FifteenMB.gz")
if err != nil {
t.Fatal(err)
}
defer resp.Body.Close()
reReader, err := diskbufferreader.New(resp.Body)
byteBuffer := bytes.NewBuffer(make([]byte, ChunkSize*9))
reReader, err := diskbufferreader.New(byteBuffer)
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit 1a1c2e2

Please sign in to comment.