mirror of
https://github.com/rclone/rclone
synced 2024-12-22 13:03:02 +01:00
fstest: remove WinPath from fstest.Item
This commit is contained in:
parent
4627ac5709
commit
97a218903c
@ -1323,7 +1323,6 @@ func TestDirMove(t *testing.T) {
|
||||
|
||||
for i := range files {
|
||||
files[i].Path = strings.Replace(files[i].Path, "A1/", "A2/", -1)
|
||||
files[i].WinPath = ""
|
||||
}
|
||||
|
||||
fstest.CheckListingWithPrecision(
|
||||
@ -1353,7 +1352,6 @@ func TestDirMove(t *testing.T) {
|
||||
|
||||
for i := range files {
|
||||
files[i].Path = strings.Replace(files[i].Path, "A2/", "A3/", -1)
|
||||
files[i].WinPath = ""
|
||||
}
|
||||
|
||||
fstest.CheckListingWithPrecision(
|
||||
|
@ -88,7 +88,6 @@ type Item struct {
|
||||
Hashes map[hash.Type]string
|
||||
ModTime time.Time
|
||||
Size int64
|
||||
WinPath string
|
||||
}
|
||||
|
||||
// NewItem creates an item from a string content
|
||||
@ -181,7 +180,6 @@ func NewItems(items []Item) *Items {
|
||||
// Fill up byName
|
||||
for i := range items {
|
||||
is.byName[Normalize(items[i].Path)] = &items[i]
|
||||
is.byNameAlt[Normalize(items[i].WinPath)] = &items[i]
|
||||
}
|
||||
return is
|
||||
}
|
||||
@ -196,7 +194,6 @@ func (is *Items) Find(t *testing.T, obj fs.Object, precision time.Duration) {
|
||||
}
|
||||
if i != nil {
|
||||
delete(is.byName, i.Path)
|
||||
delete(is.byName, i.WinPath)
|
||||
i.Check(t, obj, precision)
|
||||
}
|
||||
}
|
||||
@ -214,21 +211,14 @@ func (is *Items) Done(t *testing.T) {
|
||||
// makeListingFromItems returns a string representation of the items
|
||||
//
|
||||
// it returns two possible strings, one normal and one for windows
|
||||
func makeListingFromItems(items []Item) (string, string) {
|
||||
nameLengths1 := make([]string, len(items))
|
||||
nameLengths2 := make([]string, len(items))
|
||||
func makeListingFromItems(items []Item) string {
|
||||
nameLengths := make([]string, len(items))
|
||||
for i, item := range items {
|
||||
remote1 := Normalize(item.Path)
|
||||
remote2 := remote1
|
||||
if item.WinPath != "" {
|
||||
remote2 = item.WinPath
|
||||
remote := Normalize(item.Path)
|
||||
nameLengths[i] = fmt.Sprintf("%s (%d)", remote, item.Size)
|
||||
}
|
||||
nameLengths1[i] = fmt.Sprintf("%s (%d)", remote1, item.Size)
|
||||
nameLengths2[i] = fmt.Sprintf("%s (%d)", remote2, item.Size)
|
||||
}
|
||||
sort.Strings(nameLengths1)
|
||||
sort.Strings(nameLengths2)
|
||||
return strings.Join(nameLengths1, ", "), strings.Join(nameLengths2, ", ")
|
||||
sort.Strings(nameLengths)
|
||||
return strings.Join(nameLengths, ", ")
|
||||
}
|
||||
|
||||
// makeListingFromObjects returns a string representation of the objects
|
||||
@ -285,7 +275,7 @@ func CheckListingWithRoot(t *testing.T, f fs.Fs, dir string, items []Item, expec
|
||||
var err error
|
||||
var retries = *ListRetries
|
||||
sleep := time.Second / 2
|
||||
wantListing1, wantListing2 := makeListingFromItems(items)
|
||||
wantListing := makeListingFromItems(items)
|
||||
gotListing := "<unset>"
|
||||
listingOK := false
|
||||
for i := 1; i <= retries; i++ {
|
||||
@ -295,7 +285,7 @@ func CheckListingWithRoot(t *testing.T, f fs.Fs, dir string, items []Item, expec
|
||||
}
|
||||
|
||||
gotListing = makeListingFromObjects(objs)
|
||||
listingOK = wantListing1 == gotListing || wantListing2 == gotListing
|
||||
listingOK = wantListing == gotListing
|
||||
if listingOK && (expectedDirs == nil || len(dirs) == len(expectedDirs)) {
|
||||
// Put an extra sleep in if we did any retries just to make sure it really
|
||||
// is consistent (here is looking at you Amazon Drive!)
|
||||
@ -314,7 +304,7 @@ func CheckListingWithRoot(t *testing.T, f fs.Fs, dir string, items []Item, expec
|
||||
doDirCacheFlush()
|
||||
}
|
||||
}
|
||||
assert.True(t, listingOK, fmt.Sprintf("listing wrong, want\n %s or\n %s got\n %s", wantListing1, wantListing2, gotListing))
|
||||
assert.True(t, listingOK, fmt.Sprintf("listing wrong, want\n %s got\n %s", wantListing, gotListing))
|
||||
for _, obj := range objs {
|
||||
require.NotNil(t, obj)
|
||||
is.Find(t, obj, precision)
|
||||
@ -368,7 +358,7 @@ func CompareItems(t *testing.T, entries fs.DirEntries, items []Item, expectedDir
|
||||
is := NewItems(items)
|
||||
var objs []fs.Object
|
||||
var dirs []fs.Directory
|
||||
wantListing1, wantListing2 := makeListingFromItems(items)
|
||||
wantListing := makeListingFromItems(items)
|
||||
for _, entry := range entries {
|
||||
switch x := entry.(type) {
|
||||
case fs.Directory:
|
||||
@ -382,8 +372,8 @@ func CompareItems(t *testing.T, entries fs.DirEntries, items []Item, expectedDir
|
||||
}
|
||||
|
||||
gotListing := makeListingFromObjects(objs)
|
||||
listingOK := wantListing1 == gotListing || wantListing2 == gotListing
|
||||
assert.True(t, listingOK, fmt.Sprintf("%s not equal, want\n %s or\n %s got\n %s", what, wantListing1, wantListing2, gotListing))
|
||||
listingOK := wantListing == gotListing
|
||||
assert.True(t, listingOK, fmt.Sprintf("%s not equal, want\n %s got\n %s", what, wantListing, gotListing))
|
||||
for _, obj := range objs {
|
||||
require.NotNil(t, obj)
|
||||
is.Find(t, obj, precision)
|
||||
|
@ -292,7 +292,6 @@ func Run(t *testing.T, opt *Opt) {
|
||||
file2 = fstest.Item{
|
||||
ModTime: fstest.Time("2001-02-03T04:05:10.123123123Z"),
|
||||
Path: `hello? sausage/êé/Hello, 世界/ " ' @ < > & ? + ≠/z.txt`,
|
||||
WinPath: `hello_ sausage/êé/Hello, 世界/ _ ' @ _ _ & _ + ≠/z.txt`,
|
||||
}
|
||||
isLocalRemote bool
|
||||
purged bool // whether the dir has been purged or not
|
||||
@ -832,10 +831,6 @@ func Run(t *testing.T, opt *Opt) {
|
||||
dir, _ := path.Split(fileName)
|
||||
dir = dir[:len(dir)-1]
|
||||
objs, dirs, err = walk.GetAll(context.Background(), remote, dir, true, -1)
|
||||
if err != fs.ErrorDirNotFound {
|
||||
break
|
||||
}
|
||||
fileName = file2.WinPath
|
||||
}
|
||||
require.NoError(t, err)
|
||||
require.Len(t, objs, 1)
|
||||
@ -951,7 +946,6 @@ func Run(t *testing.T, opt *Opt) {
|
||||
// check happy path, i.e. no naming conflicts when rename and move are two
|
||||
// separate operations
|
||||
file2Move.Path = "other.txt"
|
||||
file2Move.WinPath = ""
|
||||
src := findObject(t, remote, file2.Path)
|
||||
dst, err := doMove(context.Background(), src, file2Move.Path)
|
||||
if err == fs.ErrorCantMove {
|
||||
@ -1036,7 +1030,6 @@ func Run(t *testing.T, opt *Opt) {
|
||||
file1Copy.Path = path.Join(newName, file1.Path)
|
||||
file2Copy := file2
|
||||
file2Copy.Path = path.Join(newName, file2.Path)
|
||||
file2Copy.WinPath = path.Join(newName, file2.WinPath)
|
||||
fstest.CheckListingWithPrecision(t, newRemote, []fstest.Item{file2Copy, file1Copy}, []string{
|
||||
"new_name",
|
||||
"new_name/sub_new_name",
|
||||
@ -1261,7 +1254,6 @@ func Run(t *testing.T, opt *Opt) {
|
||||
remoteName := subRemoteName + "/" + file2.Path
|
||||
file2Copy := file2
|
||||
file2Copy.Path = "z.txt"
|
||||
file2Copy.WinPath = ""
|
||||
fileRemote, err := fs.NewFs(remoteName)
|
||||
require.NotNil(t, fileRemote)
|
||||
assert.Equal(t, fs.ErrorIsFile, err)
|
||||
@ -1304,7 +1296,6 @@ func Run(t *testing.T, opt *Opt) {
|
||||
file1Root.Path = path.Join(configLeaf, file1Root.Path)
|
||||
file2Root := file2
|
||||
file2Root.Path = path.Join(configLeaf, file2Root.Path)
|
||||
file2Root.WinPath = path.Join(configLeaf, file2Root.WinPath)
|
||||
var dirs []string
|
||||
dir := file2.Path
|
||||
for {
|
||||
|
Loading…
Reference in New Issue
Block a user