From f680b9f1ff4aa6e319b52dd4dd57dfd8dd4a00b5 Mon Sep 17 00:00:00 2001 From: Marius Date: Mon, 11 Jul 2022 15:01:24 +0200 Subject: [PATCH] s3store: Fix tests by adding ContentLength property --- pkg/s3store/s3store_test.go | 77 ++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 35 deletions(-) diff --git a/pkg/s3store/s3store_test.go b/pkg/s3store/s3store_test.go index 7850248..47e3e64 100644 --- a/pkg/s3store/s3store_test.go +++ b/pkg/s3store/s3store_test.go @@ -750,29 +750,32 @@ func TestWriteChunk(t *testing.T) { // From WriteChunk s3obj.EXPECT().UploadPartWithContext(context.Background(), NewUploadPartInputMatcher(&s3.UploadPartInput{ - Bucket: aws.String("bucket"), - Key: aws.String("uploadId"), - UploadId: aws.String("multipartId"), - PartNumber: aws.Int64(3), - Body: bytes.NewReader([]byte("1234")), + Bucket: aws.String("bucket"), + Key: aws.String("uploadId"), + UploadId: aws.String("multipartId"), + PartNumber: aws.Int64(3), + Body: bytes.NewReader([]byte("1234")), + ContentLength: aws.Int64(4), })).Return(&s3.UploadPartOutput{ ETag: aws.String("etag-3"), }, nil) s3obj.EXPECT().UploadPartWithContext(context.Background(), NewUploadPartInputMatcher(&s3.UploadPartInput{ - Bucket: aws.String("bucket"), - Key: aws.String("uploadId"), - UploadId: aws.String("multipartId"), - PartNumber: aws.Int64(4), - Body: bytes.NewReader([]byte("5678")), + Bucket: aws.String("bucket"), + Key: aws.String("uploadId"), + UploadId: aws.String("multipartId"), + PartNumber: aws.Int64(4), + Body: bytes.NewReader([]byte("5678")), + ContentLength: aws.Int64(4), })).Return(&s3.UploadPartOutput{ ETag: aws.String("etag-4"), }, nil) s3obj.EXPECT().UploadPartWithContext(context.Background(), NewUploadPartInputMatcher(&s3.UploadPartInput{ - Bucket: aws.String("bucket"), - Key: aws.String("uploadId"), - UploadId: aws.String("multipartId"), - PartNumber: aws.Int64(5), - Body: bytes.NewReader([]byte("90AB")), + Bucket: aws.String("bucket"), + Key: aws.String("uploadId"), + UploadId: aws.String("multipartId"), + PartNumber: aws.Int64(5), + Body: bytes.NewReader([]byte("90AB")), + ContentLength: aws.Int64(4), })).Return(&s3.UploadPartOutput{ ETag: aws.String("etag-5"), }, nil) @@ -888,20 +891,22 @@ func TestWriteChunkPrependsIncompletePart(t *testing.T) { }).Return(&s3.DeleteObjectOutput{}, nil) s3obj.EXPECT().UploadPartWithContext(context.Background(), NewUploadPartInputMatcher(&s3.UploadPartInput{ - Bucket: aws.String("bucket"), - Key: aws.String("uploadId"), - UploadId: aws.String("multipartId"), - PartNumber: aws.Int64(1), - Body: bytes.NewReader([]byte("1234")), + Bucket: aws.String("bucket"), + Key: aws.String("uploadId"), + UploadId: aws.String("multipartId"), + PartNumber: aws.Int64(1), + Body: bytes.NewReader([]byte("1234")), + ContentLength: aws.Int64(4), })).Return(&s3.UploadPartOutput{ ETag: aws.String("etag-1"), }, nil) s3obj.EXPECT().UploadPartWithContext(context.Background(), NewUploadPartInputMatcher(&s3.UploadPartInput{ - Bucket: aws.String("bucket"), - Key: aws.String("uploadId"), - UploadId: aws.String("multipartId"), - PartNumber: aws.Int64(2), - Body: bytes.NewReader([]byte("5")), + Bucket: aws.String("bucket"), + Key: aws.String("uploadId"), + UploadId: aws.String("multipartId"), + PartNumber: aws.Int64(2), + Body: bytes.NewReader([]byte("5")), + ContentLength: aws.Int64(1), })).Return(&s3.UploadPartOutput{ ETag: aws.String("etag-2"), }, nil) @@ -958,11 +963,12 @@ func TestWriteChunkPrependsIncompletePartAndWritesANewIncompletePart(t *testing. }).Return(&s3.DeleteObjectOutput{}, nil) s3obj.EXPECT().UploadPartWithContext(context.Background(), NewUploadPartInputMatcher(&s3.UploadPartInput{ - Bucket: aws.String("bucket"), - Key: aws.String("uploadId"), - UploadId: aws.String("multipartId"), - PartNumber: aws.Int64(1), - Body: bytes.NewReader([]byte("1234")), + Bucket: aws.String("bucket"), + Key: aws.String("uploadId"), + UploadId: aws.String("multipartId"), + PartNumber: aws.Int64(1), + Body: bytes.NewReader([]byte("1234")), + ContentLength: aws.Int64(4), })).Return(&s3.UploadPartOutput{ ETag: aws.String("etag-1"), }, nil) @@ -1019,11 +1025,12 @@ func TestWriteChunkAllowTooSmallLast(t *testing.T) { Key: aws.String("uploadId.part"), }).Return(nil, awserr.New("AccessDenied", "Access Denied.", nil)) s3obj.EXPECT().UploadPartWithContext(context.Background(), NewUploadPartInputMatcher(&s3.UploadPartInput{ - Bucket: aws.String("bucket"), - Key: aws.String("uploadId"), - UploadId: aws.String("multipartId"), - PartNumber: aws.Int64(3), - Body: bytes.NewReader([]byte("1234567890")), + Bucket: aws.String("bucket"), + Key: aws.String("uploadId"), + UploadId: aws.String("multipartId"), + PartNumber: aws.Int64(3), + Body: bytes.NewReader([]byte("1234567890")), + ContentLength: aws.Int64(10), })).Return(&s3.UploadPartOutput{ ETag: aws.String("etag-3"), }, nil)