huaweidrive: run the chunked upload integration tests
Implement SetUploadChunkSizer and SetUploadCutoffer in the tests so fstests can exercise the resumable upload path with small chunk sizes.
This commit is contained in:
@@ -19,15 +19,49 @@ import (
|
|||||||
"github.com/rclone/rclone/lib/encoder"
|
"github.com/rclone/rclone/lib/encoder"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Limits on the chunk size accepted by the resumable upload API
|
||||||
|
const (
|
||||||
|
minChunkSize = 256 * fs.Kibi
|
||||||
|
maxChunkSize = 64 * fs.Mebi
|
||||||
|
)
|
||||||
|
|
||||||
// TestIntegration runs integration tests against the remote
|
// TestIntegration runs integration tests against the remote
|
||||||
func TestIntegration(t *testing.T) {
|
func TestIntegration(t *testing.T) {
|
||||||
fstests.Run(t, &fstests.Opt{
|
fstests.Run(t, &fstests.Opt{
|
||||||
RemoteName: "TestHuaweiDrive:",
|
RemoteName: "TestHuaweiDrive:",
|
||||||
NilObject: (*Object)(nil),
|
NilObject: (*Object)(nil),
|
||||||
SkipBadWindowsCharacters: true,
|
SkipBadWindowsCharacters: true,
|
||||||
|
ChunkedUpload: fstests.ChunkedUploadConfig{
|
||||||
|
MinChunkSize: minChunkSize,
|
||||||
|
MaxChunkSize: maxChunkSize,
|
||||||
|
CeilChunkSize: fstests.NextPowerOfTwo,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetUploadChunkSize changes the configured chunk size, returning the old value.
|
||||||
|
//
|
||||||
|
// It is only called by the integration tests while no transfer is in progress.
|
||||||
|
func (f *Fs) SetUploadChunkSize(cs fs.SizeSuffix) (fs.SizeSuffix, error) {
|
||||||
|
var old fs.SizeSuffix
|
||||||
|
old, f.opt.ChunkSize = f.opt.ChunkSize, cs
|
||||||
|
return old, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUploadCutoff changes the configured upload cutoff, returning the old value.
|
||||||
|
//
|
||||||
|
// It is only called by the integration tests while no transfer is in progress.
|
||||||
|
func (f *Fs) SetUploadCutoff(cutoff fs.SizeSuffix) (fs.SizeSuffix, error) {
|
||||||
|
var old fs.SizeSuffix
|
||||||
|
old, f.opt.UploadCutoff = f.opt.UploadCutoff, cutoff
|
||||||
|
return old, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ fstests.SetUploadChunkSizer = (*Fs)(nil)
|
||||||
|
_ fstests.SetUploadCutoffer = (*Fs)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
// TestNewFs tests the NewFs constructor
|
// TestNewFs tests the NewFs constructor
|
||||||
func TestNewFs(t *testing.T) {
|
func TestNewFs(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|||||||
Reference in New Issue
Block a user