operations: fix Overlapping test for Windows native paths

This commit is contained in:
Nick Craig-Wood 2019-02-28 11:39:32 +00:00
parent 52c6b373cc
commit e3bceb9083
3 changed files with 7 additions and 2 deletions

View File

@ -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 += "/"
}

View File

@ -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},
} {

View File

@ -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))