Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
Hongyu Zhou committed Aug 9, 2023
1 parent ffe9028 commit 2545d47
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion pkg/reflector/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (d *S3Downloader) DownloadTo(w io.Writer) (n int64, err error) {
defer os.Remove(file.Name())

start := time.Now()
numBytes, err := downloader.Download(context.TODO(), file, &s3.GetObjectInput{
numBytes, err := downloader.Download(context.Background(), file, &s3.GetObjectInput{
Bucket: aws.String(d.Bucket),
Key: aws.String(d.Key),
})
Expand All @@ -76,6 +76,11 @@ func (d *S3Downloader) DownloadTo(w io.Writer) (n int64, err error) {
if err != nil {
return n, errors.Wrap(err, "unzip snapshot")
}
} else {
n, err = io.Copy(w, file)
if err != nil {
return n, errors.Wrap(err, "copy snapshot")
}
}

events.Log("LDB inflated %d -> %d bytes", numBytes, n)
Expand Down
3 changes: 2 additions & 1 deletion pkg/reflector/download_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ func TestS3DownloadErrors(t *testing.T) {
s3Client: func() reflector.S3Client {
f := &fakes.FakeS3Client{}
f.GetObjectReturns(&s3.GetObjectOutput{
Body: ioutil.NopCloser(strings.NewReader("data")),
Body: ioutil.NopCloser(strings.NewReader("data")),
ContentLength: 4,
}, nil)
return f
},
Expand Down

0 comments on commit 2545d47

Please sign in to comment.