mirror of
https://github.com/rclone/rclone.git
synced 2025-12-15 15:53:41 +00:00
accounting: check for max transfer in WriteTo
Before this change the max transfer tests were failing for remotes which were using WriterTo.
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/rclone/rclone/fs"
|
||||
"github.com/rclone/rclone/fs/asyncreader"
|
||||
"github.com/rclone/rclone/fs/fserrors"
|
||||
"github.com/rclone/rclone/lib/readers"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@@ -278,6 +279,27 @@ func TestAccountMaxTransfer(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestAccountMaxTransferWriteTo(t *testing.T) {
|
||||
old := fs.Config.MaxTransfer
|
||||
oldMode := fs.Config.CutoffMode
|
||||
|
||||
fs.Config.MaxTransfer = 15
|
||||
defer func() {
|
||||
fs.Config.MaxTransfer = old
|
||||
fs.Config.CutoffMode = oldMode
|
||||
}()
|
||||
|
||||
in := ioutil.NopCloser(readers.NewPatternReader(1024))
|
||||
stats := NewStats()
|
||||
acc := newAccountSizeName(stats, in, 1, "test")
|
||||
|
||||
var b bytes.Buffer
|
||||
|
||||
n, err := acc.WriteTo(&b)
|
||||
assert.Equal(t, int64(15), n)
|
||||
assert.Equal(t, ErrorMaxTransferLimitReachedFatal, err)
|
||||
}
|
||||
|
||||
func TestShortenName(t *testing.T) {
|
||||
for _, test := range []struct {
|
||||
in string
|
||||
|
||||
Reference in New Issue
Block a user