Skip to content

Commit 2545d47

Browse files
author
Hongyu Zhou
committed
fix test
1 parent ffe9028 commit 2545d47

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

pkg/reflector/download.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func (d *S3Downloader) DownloadTo(w io.Writer) (n int64, err error) {
5353
defer os.Remove(file.Name())
5454

5555
start := time.Now()
56-
numBytes, err := downloader.Download(context.TODO(), file, &s3.GetObjectInput{
56+
numBytes, err := downloader.Download(context.Background(), file, &s3.GetObjectInput{
5757
Bucket: aws.String(d.Bucket),
5858
Key: aws.String(d.Key),
5959
})
@@ -76,6 +76,11 @@ func (d *S3Downloader) DownloadTo(w io.Writer) (n int64, err error) {
7676
if err != nil {
7777
return n, errors.Wrap(err, "unzip snapshot")
7878
}
79+
} else {
80+
n, err = io.Copy(w, file)
81+
if err != nil {
82+
return n, errors.Wrap(err, "copy snapshot")
83+
}
7984
}
8085

8186
events.Log("LDB inflated %d -> %d bytes", numBytes, n)

pkg/reflector/download_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ func TestS3DownloadErrors(t *testing.T) {
3838
s3Client: func() reflector.S3Client {
3939
f := &fakes.FakeS3Client{}
4040
f.GetObjectReturns(&s3.GetObjectOutput{
41-
Body: ioutil.NopCloser(strings.NewReader("data")),
41+
Body: ioutil.NopCloser(strings.NewReader("data")),
42+
ContentLength: 4,
4243
}, nil)
4344
return f
4445
},

0 commit comments

Comments
 (0)