2017-09-16 18:49:09 +00:00
|
|
|
package gcsstore_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
2019-06-11 14:16:02 +00:00
|
|
|
"context"
|
2017-09-16 18:49:09 +00:00
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
|
2018-05-25 10:14:16 +00:00
|
|
|
"cloud.google.com/go/storage"
|
2017-09-16 18:49:09 +00:00
|
|
|
"github.com/golang/mock/gomock"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
2019-06-11 16:23:20 +00:00
|
|
|
"github.com/tus/tusd/pkg/gcsstore"
|
|
|
|
"github.com/tus/tusd/pkg/handler"
|
2017-09-16 18:49:09 +00:00
|
|
|
)
|
|
|
|
|
2019-06-11 16:23:20 +00:00
|
|
|
// go:generate mockgen -destination=./gcsstore_mock_test.go -package=gcsstore_test github.com/tus/tusd/pkg/gcsstore GCSReader,GCSAPI
|
2017-09-16 18:49:09 +00:00
|
|
|
|
|
|
|
const mockID = "123456789abcdefghijklmnopqrstuvwxyz"
|
|
|
|
const mockBucket = "bucket"
|
|
|
|
const mockSize = 1337
|
|
|
|
const mockReaderData = "helloworld"
|
|
|
|
|
2019-08-19 09:08:24 +00:00
|
|
|
var mockTusdInfoJson = fmt.Sprintf(`{"ID":"%s","Size":%d,"MetaData":{"foo":"bar"},"Storage":{"Bucket":"bucket","Key":"%s","Type":"gcsstore"}}`, mockID, mockSize, mockID)
|
2019-06-11 16:23:20 +00:00
|
|
|
var mockTusdInfo = handler.FileInfo{
|
2017-09-16 18:49:09 +00:00
|
|
|
ID: mockID,
|
|
|
|
Size: mockSize,
|
|
|
|
MetaData: map[string]string{
|
|
|
|
"foo": "bar",
|
|
|
|
},
|
2019-08-19 09:08:24 +00:00
|
|
|
Storage: map[string]string{
|
|
|
|
"Type": "gcsstore",
|
|
|
|
"Bucket": mockBucket,
|
|
|
|
"Key": mockID,
|
|
|
|
},
|
2017-09-16 18:49:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var mockPartial0 = fmt.Sprintf("%s_0", mockID)
|
|
|
|
var mockPartial1 = fmt.Sprintf("%s_1", mockID)
|
|
|
|
var mockPartial2 = fmt.Sprintf("%s_2", mockID)
|
|
|
|
var mockPartials = []string{mockPartial0, mockPartial1, mockPartial2}
|
|
|
|
|
|
|
|
func TestNewUpload(t *testing.T) {
|
|
|
|
mockCtrl := gomock.NewController(t)
|
|
|
|
defer mockCtrl.Finish()
|
|
|
|
assert := assert.New(t)
|
|
|
|
|
|
|
|
service := NewMockGCSAPI(mockCtrl)
|
|
|
|
store := gcsstore.New(mockBucket, service)
|
|
|
|
|
|
|
|
assert.Equal(store.Bucket, mockBucket)
|
|
|
|
|
|
|
|
data, err := json.Marshal(mockTusdInfo)
|
|
|
|
assert.Nil(err)
|
|
|
|
|
|
|
|
r := bytes.NewReader(data)
|
|
|
|
|
|
|
|
params := gcsstore.GCSObjectParams{
|
|
|
|
Bucket: store.Bucket,
|
|
|
|
ID: fmt.Sprintf("%s.info", mockID),
|
|
|
|
}
|
|
|
|
|
2018-07-25 16:51:38 +00:00
|
|
|
ctx := context.Background()
|
|
|
|
service.EXPECT().WriteObject(ctx, params, r).Return(int64(r.Len()), nil)
|
2017-09-16 18:49:09 +00:00
|
|
|
|
2019-09-15 11:43:59 +00:00
|
|
|
upload, err := store.NewUpload(context.Background(), mockTusdInfo)
|
2017-09-16 18:49:09 +00:00
|
|
|
assert.Nil(err)
|
2019-09-10 09:09:07 +00:00
|
|
|
assert.NotNil(upload)
|
2017-09-16 18:49:09 +00:00
|
|
|
}
|
|
|
|
|
2019-06-02 13:55:41 +00:00
|
|
|
func TestNewUploadWithPrefix(t *testing.T) {
|
|
|
|
mockCtrl := gomock.NewController(t)
|
|
|
|
defer mockCtrl.Finish()
|
|
|
|
assert := assert.New(t)
|
|
|
|
|
|
|
|
service := NewMockGCSAPI(mockCtrl)
|
|
|
|
store := gcsstore.New(mockBucket, service)
|
|
|
|
store.ObjectPrefix = "/path/to/file"
|
|
|
|
|
|
|
|
assert.Equal(store.Bucket, mockBucket)
|
|
|
|
|
2019-08-19 09:08:24 +00:00
|
|
|
info := mockTusdInfo
|
|
|
|
info.Storage = map[string]string{
|
|
|
|
"Type": "gcsstore",
|
|
|
|
"Bucket": mockBucket,
|
|
|
|
"Key": "/path/to/file/" + mockID,
|
|
|
|
}
|
|
|
|
data, err := json.Marshal(info)
|
2019-06-02 13:55:41 +00:00
|
|
|
assert.Nil(err)
|
|
|
|
|
|
|
|
r := bytes.NewReader(data)
|
|
|
|
|
|
|
|
params := gcsstore.GCSObjectParams{
|
|
|
|
Bucket: store.Bucket,
|
|
|
|
ID: fmt.Sprintf("%s.info", "/path/to/file/"+mockID),
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx := context.Background()
|
|
|
|
service.EXPECT().WriteObject(ctx, params, r).Return(int64(r.Len()), nil)
|
|
|
|
|
2019-09-15 11:43:59 +00:00
|
|
|
upload, err := store.NewUpload(context.Background(), mockTusdInfo)
|
2019-06-02 13:55:41 +00:00
|
|
|
assert.Nil(err)
|
2019-09-10 09:09:07 +00:00
|
|
|
assert.NotNil(upload)
|
2019-06-02 13:55:41 +00:00
|
|
|
}
|
|
|
|
|
2017-09-16 18:49:09 +00:00
|
|
|
type MockGetInfoReader struct{}
|
|
|
|
|
|
|
|
func (r MockGetInfoReader) Close() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r MockGetInfoReader) ContentType() string {
|
|
|
|
return "text/plain; charset=utf-8"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r MockGetInfoReader) Read(p []byte) (int, error) {
|
|
|
|
copy(p, mockTusdInfoJson)
|
|
|
|
return len(p), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r MockGetInfoReader) Remain() int64 {
|
|
|
|
return int64(len(mockTusdInfoJson))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r MockGetInfoReader) Size() int64 {
|
|
|
|
return int64(len(mockTusdInfoJson))
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestGetInfo(t *testing.T) {
|
|
|
|
mockCtrl := gomock.NewController(t)
|
|
|
|
defer mockCtrl.Finish()
|
|
|
|
assert := assert.New(t)
|
|
|
|
|
|
|
|
service := NewMockGCSAPI(mockCtrl)
|
|
|
|
store := gcsstore.New(mockBucket, service)
|
|
|
|
|
|
|
|
assert.Equal(store.Bucket, mockBucket)
|
|
|
|
|
|
|
|
params := gcsstore.GCSObjectParams{
|
|
|
|
Bucket: store.Bucket,
|
|
|
|
ID: fmt.Sprintf("%s.info", mockID),
|
|
|
|
}
|
|
|
|
|
|
|
|
r := MockGetInfoReader{}
|
|
|
|
|
|
|
|
filterParams := gcsstore.GCSFilterParams{
|
|
|
|
Bucket: store.Bucket,
|
2019-10-09 12:44:13 +00:00
|
|
|
Prefix: mockID,
|
2017-09-16 18:49:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mockObjectParams0 := gcsstore.GCSObjectParams{
|
|
|
|
Bucket: store.Bucket,
|
|
|
|
ID: mockPartial0,
|
|
|
|
}
|
|
|
|
|
|
|
|
mockObjectParams1 := gcsstore.GCSObjectParams{
|
|
|
|
Bucket: store.Bucket,
|
|
|
|
ID: mockPartial1,
|
|
|
|
}
|
|
|
|
|
|
|
|
mockObjectParams2 := gcsstore.GCSObjectParams{
|
|
|
|
Bucket: store.Bucket,
|
|
|
|
ID: mockPartial2,
|
|
|
|
}
|
|
|
|
|
|
|
|
var size int64 = 100
|
|
|
|
|
|
|
|
mockTusdInfo.Offset = 300
|
|
|
|
offsetInfoData, err := json.Marshal(mockTusdInfo)
|
|
|
|
assert.Nil(err)
|
|
|
|
|
|
|
|
infoR := bytes.NewReader(offsetInfoData)
|
|
|
|
|
2018-07-25 16:51:38 +00:00
|
|
|
ctx := context.Background()
|
2017-09-16 18:49:09 +00:00
|
|
|
gomock.InOrder(
|
2018-07-25 16:51:38 +00:00
|
|
|
service.EXPECT().ReadObject(ctx, params).Return(r, nil),
|
|
|
|
service.EXPECT().FilterObjects(ctx, filterParams).Return(mockPartials, nil),
|
2017-09-16 18:49:09 +00:00
|
|
|
)
|
|
|
|
|
2019-06-11 14:52:36 +00:00
|
|
|
ctxCancel, cancel := context.WithCancel(ctx)
|
2018-07-25 16:51:38 +00:00
|
|
|
service.EXPECT().GetObjectSize(ctxCancel, mockObjectParams0).Return(size, nil)
|
|
|
|
service.EXPECT().GetObjectSize(ctxCancel, mockObjectParams1).Return(size, nil)
|
|
|
|
lastGetObjectSize := service.EXPECT().GetObjectSize(ctxCancel, mockObjectParams2).Return(size, nil)
|
|
|
|
|
|
|
|
service.EXPECT().WriteObject(ctx, params, infoR).Return(int64(len(offsetInfoData)), nil).After(lastGetObjectSize)
|
|
|
|
|
2019-09-15 11:43:59 +00:00
|
|
|
upload, err := store.GetUpload(context.Background(), mockID)
|
2019-09-10 09:09:07 +00:00
|
|
|
assert.Nil(err)
|
|
|
|
|
2019-09-15 11:43:59 +00:00
|
|
|
info, err := upload.GetInfo(context.Background())
|
2017-09-16 18:49:09 +00:00
|
|
|
assert.Nil(err)
|
|
|
|
assert.Equal(mockTusdInfo, info)
|
2019-06-11 14:52:36 +00:00
|
|
|
|
|
|
|
// Cancel the context to avoid getting an error from `go vet`
|
|
|
|
cancel()
|
2017-09-16 18:49:09 +00:00
|
|
|
}
|
|
|
|
|
2018-05-25 10:14:16 +00:00
|
|
|
func TestGetInfoNotFound(t *testing.T) {
|
|
|
|
mockCtrl := gomock.NewController(t)
|
|
|
|
defer mockCtrl.Finish()
|
|
|
|
assert := assert.New(t)
|
|
|
|
|
|
|
|
service := NewMockGCSAPI(mockCtrl)
|
|
|
|
store := gcsstore.New(mockBucket, service)
|
|
|
|
|
|
|
|
params := gcsstore.GCSObjectParams{
|
|
|
|
Bucket: store.Bucket,
|
|
|
|
ID: fmt.Sprintf("%s.info", mockID),
|
|
|
|
}
|
|
|
|
|
2018-07-25 16:51:38 +00:00
|
|
|
ctx := context.Background()
|
2018-05-25 10:14:16 +00:00
|
|
|
gomock.InOrder(
|
2018-07-25 16:51:38 +00:00
|
|
|
service.EXPECT().ReadObject(ctx, params).Return(nil, storage.ErrObjectNotExist),
|
2018-05-25 10:14:16 +00:00
|
|
|
)
|
|
|
|
|
2019-09-15 11:43:59 +00:00
|
|
|
upload, err := store.GetUpload(context.Background(), mockID)
|
2019-09-10 09:09:07 +00:00
|
|
|
assert.Nil(err)
|
|
|
|
|
2019-09-15 11:43:59 +00:00
|
|
|
_, err = upload.GetInfo(context.Background())
|
2019-06-11 16:23:20 +00:00
|
|
|
assert.Equal(handler.ErrNotFound, err)
|
2018-05-25 10:14:16 +00:00
|
|
|
}
|
|
|
|
|
2017-09-16 18:49:09 +00:00
|
|
|
type MockGetReader struct{}
|
|
|
|
|
|
|
|
func (r MockGetReader) Close() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r MockGetReader) ContentType() string {
|
|
|
|
return "text/plain; charset=utf-8"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r MockGetReader) Read(p []byte) (int, error) {
|
|
|
|
copy(p, mockReaderData)
|
|
|
|
return len(p), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r MockGetReader) Remain() int64 {
|
|
|
|
return int64(len(mockReaderData))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r MockGetReader) Size() int64 {
|
|
|
|
return int64(len(mockReaderData))
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestGetReader(t *testing.T) {
|
|
|
|
mockCtrl := gomock.NewController(t)
|
|
|
|
defer mockCtrl.Finish()
|
|
|
|
assert := assert.New(t)
|
|
|
|
|
|
|
|
service := NewMockGCSAPI(mockCtrl)
|
|
|
|
store := gcsstore.New(mockBucket, service)
|
|
|
|
|
|
|
|
assert.Equal(store.Bucket, mockBucket)
|
|
|
|
|
|
|
|
params := gcsstore.GCSObjectParams{
|
|
|
|
Bucket: store.Bucket,
|
|
|
|
ID: mockID,
|
|
|
|
}
|
|
|
|
|
|
|
|
r := MockGetReader{}
|
|
|
|
|
2018-07-25 16:51:38 +00:00
|
|
|
ctx := context.Background()
|
|
|
|
service.EXPECT().ReadObject(ctx, params).Return(r, nil)
|
2019-09-10 09:09:07 +00:00
|
|
|
|
2019-09-15 11:43:59 +00:00
|
|
|
upload, err := store.GetUpload(context.Background(), mockID)
|
2019-09-10 09:09:07 +00:00
|
|
|
assert.Nil(err)
|
|
|
|
|
2019-09-15 11:43:59 +00:00
|
|
|
reader, err := upload.GetReader(context.Background())
|
2017-09-16 18:49:09 +00:00
|
|
|
assert.Nil(err)
|
|
|
|
|
|
|
|
buf := make([]byte, len(mockReaderData))
|
|
|
|
_, err = reader.Read(buf)
|
|
|
|
|
|
|
|
assert.Nil(err)
|
|
|
|
assert.Equal(mockReaderData, string(buf[:]))
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestTerminate(t *testing.T) {
|
|
|
|
mockCtrl := gomock.NewController(t)
|
|
|
|
defer mockCtrl.Finish()
|
|
|
|
assert := assert.New(t)
|
|
|
|
|
|
|
|
service := NewMockGCSAPI(mockCtrl)
|
|
|
|
store := gcsstore.New(mockBucket, service)
|
|
|
|
|
|
|
|
assert.Equal(store.Bucket, mockBucket)
|
|
|
|
|
|
|
|
filterParams := gcsstore.GCSFilterParams{
|
|
|
|
Bucket: store.Bucket,
|
|
|
|
Prefix: mockID,
|
|
|
|
}
|
|
|
|
|
2018-07-25 16:51:38 +00:00
|
|
|
ctx := context.Background()
|
|
|
|
service.EXPECT().DeleteObjectsWithFilter(ctx, filterParams).Return(nil)
|
2017-09-16 18:49:09 +00:00
|
|
|
|
2019-09-15 11:43:59 +00:00
|
|
|
upload, err := store.GetUpload(context.Background(), mockID)
|
2019-09-10 09:09:07 +00:00
|
|
|
assert.Nil(err)
|
|
|
|
|
2019-09-15 11:43:59 +00:00
|
|
|
err = store.AsTerminatableUpload(upload).Terminate(context.Background())
|
2017-09-16 18:49:09 +00:00
|
|
|
assert.Nil(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestFinishUpload(t *testing.T) {
|
|
|
|
mockCtrl := gomock.NewController(t)
|
|
|
|
defer mockCtrl.Finish()
|
|
|
|
assert := assert.New(t)
|
|
|
|
|
|
|
|
service := NewMockGCSAPI(mockCtrl)
|
|
|
|
store := gcsstore.New(mockBucket, service)
|
|
|
|
|
|
|
|
assert.Equal(store.Bucket, mockBucket)
|
|
|
|
|
|
|
|
filterParams := gcsstore.GCSFilterParams{
|
|
|
|
Bucket: store.Bucket,
|
|
|
|
Prefix: fmt.Sprintf("%s_", mockID),
|
|
|
|
}
|
|
|
|
|
2017-11-28 14:28:37 +00:00
|
|
|
filterParams2 := gcsstore.GCSFilterParams{
|
|
|
|
Bucket: store.Bucket,
|
2019-10-09 12:44:13 +00:00
|
|
|
Prefix: mockID,
|
2017-11-28 14:28:37 +00:00
|
|
|
}
|
|
|
|
|
2017-09-16 18:49:09 +00:00
|
|
|
composeParams := gcsstore.GCSComposeParams{
|
|
|
|
Bucket: store.Bucket,
|
|
|
|
Destination: mockID,
|
|
|
|
Sources: mockPartials,
|
|
|
|
}
|
|
|
|
|
|
|
|
infoParams := gcsstore.GCSObjectParams{
|
|
|
|
Bucket: store.Bucket,
|
|
|
|
ID: fmt.Sprintf("%s.info", mockID),
|
|
|
|
}
|
|
|
|
|
|
|
|
r := MockGetInfoReader{}
|
|
|
|
|
|
|
|
mockObjectParams0 := gcsstore.GCSObjectParams{
|
|
|
|
Bucket: store.Bucket,
|
|
|
|
ID: mockPartial0,
|
|
|
|
}
|
|
|
|
|
|
|
|
mockObjectParams1 := gcsstore.GCSObjectParams{
|
|
|
|
Bucket: store.Bucket,
|
|
|
|
ID: mockPartial1,
|
|
|
|
}
|
|
|
|
|
|
|
|
mockObjectParams2 := gcsstore.GCSObjectParams{
|
|
|
|
Bucket: store.Bucket,
|
|
|
|
ID: mockPartial2,
|
|
|
|
}
|
|
|
|
|
|
|
|
var size int64 = 100
|
|
|
|
|
|
|
|
mockTusdInfo.Offset = 300
|
|
|
|
offsetInfoData, err := json.Marshal(mockTusdInfo)
|
|
|
|
assert.Nil(err)
|
|
|
|
|
|
|
|
infoR := bytes.NewReader(offsetInfoData)
|
|
|
|
|
|
|
|
objectParams := gcsstore.GCSObjectParams{
|
|
|
|
Bucket: store.Bucket,
|
2019-10-09 12:44:13 +00:00
|
|
|
ID: mockID,
|
2017-09-16 18:49:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
metadata := map[string]string{
|
|
|
|
"foo": "bar",
|
|
|
|
}
|
|
|
|
|
2018-07-25 16:51:38 +00:00
|
|
|
ctx := context.Background()
|
2017-09-16 18:49:09 +00:00
|
|
|
gomock.InOrder(
|
2018-07-25 16:51:38 +00:00
|
|
|
service.EXPECT().FilterObjects(ctx, filterParams).Return(mockPartials, nil),
|
|
|
|
service.EXPECT().ComposeObjects(ctx, composeParams).Return(nil),
|
|
|
|
service.EXPECT().DeleteObjectsWithFilter(ctx, filterParams).Return(nil),
|
|
|
|
service.EXPECT().ReadObject(ctx, infoParams).Return(r, nil),
|
|
|
|
service.EXPECT().FilterObjects(ctx, filterParams2).Return(mockPartials, nil),
|
2017-09-16 18:49:09 +00:00
|
|
|
)
|
|
|
|
|
2019-06-11 14:52:36 +00:00
|
|
|
ctxCancel, cancel := context.WithCancel(ctx)
|
2018-07-25 16:51:38 +00:00
|
|
|
service.EXPECT().GetObjectSize(ctxCancel, mockObjectParams0).Return(size, nil)
|
|
|
|
service.EXPECT().GetObjectSize(ctxCancel, mockObjectParams1).Return(size, nil)
|
|
|
|
lastGetObjectSize := service.EXPECT().GetObjectSize(ctxCancel, mockObjectParams2).Return(size, nil)
|
|
|
|
|
|
|
|
writeObject := service.EXPECT().WriteObject(ctx, infoParams, infoR).Return(int64(len(offsetInfoData)), nil).After(lastGetObjectSize)
|
|
|
|
service.EXPECT().SetObjectMetadata(ctx, objectParams, metadata).Return(nil).After(writeObject)
|
|
|
|
|
2019-09-15 11:43:59 +00:00
|
|
|
upload, err := store.GetUpload(context.Background(), mockID)
|
2019-09-10 09:09:07 +00:00
|
|
|
assert.Nil(err)
|
|
|
|
|
2019-09-15 11:43:59 +00:00
|
|
|
err = upload.FinishUpload(context.Background())
|
2017-09-16 18:49:09 +00:00
|
|
|
assert.Nil(err)
|
2019-06-11 14:52:36 +00:00
|
|
|
|
|
|
|
// Cancel the context to avoid getting an error from `go vet`
|
|
|
|
cancel()
|
2017-09-16 18:49:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestWriteChunk(t *testing.T) {
|
|
|
|
mockCtrl := gomock.NewController(t)
|
|
|
|
defer mockCtrl.Finish()
|
|
|
|
assert := assert.New(t)
|
|
|
|
|
|
|
|
service := NewMockGCSAPI(mockCtrl)
|
|
|
|
store := gcsstore.New(mockBucket, service)
|
|
|
|
|
|
|
|
assert.Equal(store.Bucket, mockBucket)
|
|
|
|
|
|
|
|
// filter objects
|
|
|
|
filterParams := gcsstore.GCSFilterParams{
|
|
|
|
Bucket: store.Bucket,
|
|
|
|
Prefix: fmt.Sprintf("%s_", mockID),
|
|
|
|
}
|
|
|
|
|
|
|
|
var partials = []string{mockPartial0}
|
|
|
|
|
|
|
|
// write object
|
|
|
|
writeObjectParams := gcsstore.GCSObjectParams{
|
|
|
|
Bucket: store.Bucket,
|
|
|
|
ID: mockPartial1,
|
|
|
|
}
|
|
|
|
|
|
|
|
rGet := bytes.NewReader([]byte(mockReaderData))
|
|
|
|
|
2018-07-25 16:51:38 +00:00
|
|
|
ctx := context.Background()
|
2017-09-16 18:49:09 +00:00
|
|
|
gomock.InOrder(
|
2018-07-25 16:51:38 +00:00
|
|
|
service.EXPECT().FilterObjects(ctx, filterParams).Return(partials, nil),
|
|
|
|
service.EXPECT().WriteObject(ctx, writeObjectParams, rGet).Return(int64(len(mockReaderData)), nil),
|
2017-09-16 18:49:09 +00:00
|
|
|
)
|
|
|
|
|
2019-09-15 11:43:59 +00:00
|
|
|
upload, err := store.GetUpload(context.Background(), mockID)
|
2019-09-10 09:09:07 +00:00
|
|
|
assert.Nil(err)
|
|
|
|
|
2019-10-09 12:44:13 +00:00
|
|
|
reader := bytes.NewReader([]byte(mockReaderData))
|
|
|
|
var offset int64 = mockSize / 3
|
|
|
|
|
2019-09-15 11:43:59 +00:00
|
|
|
_, err = upload.WriteChunk(context.Background(), offset, reader)
|
2017-09-16 18:49:09 +00:00
|
|
|
assert.Nil(err)
|
|
|
|
}
|