Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

operations: fix Overlapping test for Windows native paths

Nick Craig-Woode3bceb90837e
diff --git a/fs/operations/operations.go b/fs/operations/operations.go
index b97fade44..ec2be9290 100644
--- a/fs/operations/operations.go
+++ b/fs/operations/operations.go
@@ -10,6 +10,7 @@ import (
"io/ioutil"
"net/http"
"path"
+ "path/filepath"
"sort"
"strconv"
"strings"
@@ -543,7 +544,7 @@ func Overlapping(fdst, fsrc fs.Info) bool {
}
// Return the Root with a trailing / if not empty
fixedRoot := func(f fs.Info) string {
- s := strings.Trim(f.Root(), "/")
+ s := strings.Trim(filepath.ToSlash(f.Root()), "/")
if s != "" {
s += "/"
}
diff --git a/fs/operations/operations_test.go b/fs/operations/operations_test.go
index 1ee69ee6a..72749fdaa 100644
--- a/fs/operations/operations_test.go
+++ b/fs/operations/operations_test.go
@@ -777,6 +777,7 @@ func TestSame(t *testing.T) {
func TestOverlapping(t *testing.T) {
a := &testFsInfo{name: "name", root: "root"}
+ slash := string(os.PathSeparator) // native path separator
for _, test := range []struct {
name string
root string
@@ -789,6 +790,8 @@ func TestOverlapping(t *testing.T) {
{"name", "roo", false},
{"name", "root/toot", true},
{"name", "root/toot/", true},
+ {"name", "root" + slash + "toot", true},
+ {"name", "root" + slash + "toot" + slash, true},
{"name", "", true},
{"name", "/", true},
} {
diff --git a/fs/sync/sync_test.go b/fs/sync/sync_test.go
index ab8522ce4..ab013cc81 100644
--- a/fs/sync/sync_test.go
+++ b/fs/sync/sync_test.go
@@ -1124,8 +1124,9 @@ func TestSyncOverlap(t *testing.T) {
require.NoError(t, err)
checkErr := func(err error) {
+ require.Error(t, err)
assert.True(t, fserrors.IsFatalError(err))
- assert.Equal(t, err.Error(), fs.ErrorOverlapping.Error())
+ assert.Equal(t, fs.ErrorOverlapping.Error(), err.Error())
}
checkErr(Sync(FremoteSync, r.Fremote))