add test file with prefix
This commit is contained in:
parent
aa8a29866f
commit
82c50f9364
|
@ -65,6 +65,35 @@ func TestNewUpload(t *testing.T) {
|
||||||
assert.Equal(id, mockID)
|
assert.Equal(id, mockID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
data, err := json.Marshal(mockTusdInfo)
|
||||||
|
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)
|
||||||
|
|
||||||
|
id, err := store.NewUpload(mockTusdInfo)
|
||||||
|
assert.Nil(err)
|
||||||
|
assert.Equal(id, mockID)
|
||||||
|
}
|
||||||
|
|
||||||
type MockGetInfoReader struct{}
|
type MockGetInfoReader struct{}
|
||||||
|
|
||||||
func (r MockGetInfoReader) Close() error {
|
func (r MockGetInfoReader) Close() error {
|
||||||
|
|
Loading…
Reference in New Issue