mirror of
https://github.com/rclone/rclone.git
synced 2024-11-30 12:34:04 +08:00
2e21c58e6a
This is done by making fs.Config private and attaching it to the context instead. The Config should be obtained with fs.GetConfig and fs.AddConfig should be used to get a new mutable config that can be changed.
44 lines
1.0 KiB
Go
44 lines
1.0 KiB
Go
// Internal tests for operations
|
|
|
|
package operations
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/rclone/rclone/fs"
|
|
"github.com/rclone/rclone/fs/object"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestSizeDiffers(t *testing.T) {
|
|
ctx := context.Background()
|
|
ci := fs.GetConfig(ctx)
|
|
when := time.Now()
|
|
for _, test := range []struct {
|
|
ignoreSize bool
|
|
srcSize int64
|
|
dstSize int64
|
|
want bool
|
|
}{
|
|
{false, 0, 0, false},
|
|
{false, 1, 2, true},
|
|
{false, 1, -1, false},
|
|
{false, -1, 1, false},
|
|
{true, 0, 0, false},
|
|
{true, 1, 2, false},
|
|
{true, 1, -1, false},
|
|
{true, -1, 1, false},
|
|
} {
|
|
src := object.NewStaticObjectInfo("a", when, test.srcSize, true, nil, nil)
|
|
dst := object.NewStaticObjectInfo("a", when, test.dstSize, true, nil, nil)
|
|
oldIgnoreSize := ci.IgnoreSize
|
|
ci.IgnoreSize = test.ignoreSize
|
|
got := sizeDiffers(ctx, src, dst)
|
|
ci.IgnoreSize = oldIgnoreSize
|
|
assert.Equal(t, test.want, got, fmt.Sprintf("ignoreSize=%v, srcSize=%v, dstSize=%v", test.ignoreSize, test.srcSize, test.dstSize))
|
|
}
|
|
}
|