github.com/rclone/rclone@v1.66.1-0.20240517100346-7b89735ae726/fs/operations/operations_internal_test.go (about) 1 // Internal tests for operations 2 3 package operations 4 5 import ( 6 "context" 7 "fmt" 8 "testing" 9 "time" 10 11 "github.com/rclone/rclone/fs" 12 "github.com/rclone/rclone/fs/object" 13 "github.com/stretchr/testify/assert" 14 ) 15 16 func TestSizeDiffers(t *testing.T) { 17 ctx := context.Background() 18 ci := fs.GetConfig(ctx) 19 when := time.Now() 20 for _, test := range []struct { 21 ignoreSize bool 22 srcSize int64 23 dstSize int64 24 want bool 25 }{ 26 {false, 0, 0, false}, 27 {false, 1, 2, true}, 28 {false, 1, -1, false}, 29 {false, -1, 1, false}, 30 {true, 0, 0, false}, 31 {true, 1, 2, false}, 32 {true, 1, -1, false}, 33 {true, -1, 1, false}, 34 } { 35 src := object.NewStaticObjectInfo("a", when, test.srcSize, true, nil, nil) 36 dst := object.NewStaticObjectInfo("a", when, test.dstSize, true, nil, nil) 37 oldIgnoreSize := ci.IgnoreSize 38 ci.IgnoreSize = test.ignoreSize 39 got := sizeDiffers(ctx, src, dst) 40 ci.IgnoreSize = oldIgnoreSize 41 assert.Equal(t, test.want, got, fmt.Sprintf("ignoreSize=%v, srcSize=%v, dstSize=%v", test.ignoreSize, test.srcSize, test.dstSize)) 42 } 43 }