mirror of https://github.com/rclone/rclone.git
operations: fix Overlapping test for Windows native paths
This commit is contained in:
parent
52c6b373cc
commit
e3bceb9083
|
@ -10,6 +10,7 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path"
|
"path"
|
||||||
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -543,7 +544,7 @@ func Overlapping(fdst, fsrc fs.Info) bool {
|
||||||
}
|
}
|
||||||
// Return the Root with a trailing / if not empty
|
// Return the Root with a trailing / if not empty
|
||||||
fixedRoot := func(f fs.Info) string {
|
fixedRoot := func(f fs.Info) string {
|
||||||
s := strings.Trim(f.Root(), "/")
|
s := strings.Trim(filepath.ToSlash(f.Root()), "/")
|
||||||
if s != "" {
|
if s != "" {
|
||||||
s += "/"
|
s += "/"
|
||||||
}
|
}
|
||||||
|
|
|
@ -777,6 +777,7 @@ func TestSame(t *testing.T) {
|
||||||
|
|
||||||
func TestOverlapping(t *testing.T) {
|
func TestOverlapping(t *testing.T) {
|
||||||
a := &testFsInfo{name: "name", root: "root"}
|
a := &testFsInfo{name: "name", root: "root"}
|
||||||
|
slash := string(os.PathSeparator) // native path separator
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
name string
|
name string
|
||||||
root string
|
root string
|
||||||
|
@ -789,6 +790,8 @@ func TestOverlapping(t *testing.T) {
|
||||||
{"name", "roo", false},
|
{"name", "roo", false},
|
||||||
{"name", "root/toot", true},
|
{"name", "root/toot", true},
|
||||||
{"name", "root/toot/", true},
|
{"name", "root/toot/", true},
|
||||||
|
{"name", "root" + slash + "toot", true},
|
||||||
|
{"name", "root" + slash + "toot" + slash, true},
|
||||||
{"name", "", true},
|
{"name", "", true},
|
||||||
{"name", "/", true},
|
{"name", "/", true},
|
||||||
} {
|
} {
|
||||||
|
|
|
@ -1124,8 +1124,9 @@ func TestSyncOverlap(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
checkErr := func(err error) {
|
checkErr := func(err error) {
|
||||||
|
require.Error(t, err)
|
||||||
assert.True(t, fserrors.IsFatalError(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))
|
checkErr(Sync(FremoteSync, r.Fremote))
|
||||||
|
|
Loading…
Reference in New Issue