Fix rename with capitalization test
This commit is contained in:
parent
cb5ef26020
commit
03506db76c
19
test/util.go
19
test/util.go
@ -133,8 +133,7 @@ func alterFiles(dir string) error {
|
|||||||
switch {
|
switch {
|
||||||
case r == 0 && comps > 2:
|
case r == 0 && comps > 2:
|
||||||
// Delete every tenth file or directory, except top levels
|
// Delete every tenth file or directory, except top levels
|
||||||
err := removeAll(path)
|
return removeAll(path)
|
||||||
return err
|
|
||||||
|
|
||||||
case r == 1 && info.Mode().IsRegular():
|
case r == 1 && info.Mode().IsRegular():
|
||||||
if info.Mode()&0200 != 0200 {
|
if info.Mode()&0200 != 0200 {
|
||||||
@ -159,8 +158,7 @@ func alterFiles(dir string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = fd.Close()
|
return fd.Close()
|
||||||
return err
|
|
||||||
|
|
||||||
// Change capitalization
|
// Change capitalization
|
||||||
case r == 2 && comps > 3 && rand.Float64() < 0.2:
|
case r == 2 && comps > 3 && rand.Float64() < 0.2:
|
||||||
@ -172,11 +170,13 @@ func alterFiles(dir string) error {
|
|||||||
base[i] = unicode.ToUpper(r)
|
base[i] = unicode.ToUpper(r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
err = osutil.TryRename(path, strings.Replace(path, filepath.Base(path), string(base), 1))
|
newPath := filepath.Join(filepath.Dir(path), string(base))
|
||||||
return err
|
if newPath != path {
|
||||||
|
return osutil.TryRename(path, newPath)
|
||||||
|
}
|
||||||
|
|
||||||
// Switch between files and directories
|
// Switch between files and directories
|
||||||
case r == 2 && comps > 3 && rand.Float64() < 0.2:
|
case r == 3 && comps > 3 && rand.Float64() < 0.2:
|
||||||
if !info.Mode().IsRegular() {
|
if !info.Mode().IsRegular() {
|
||||||
err = removeAll(path)
|
err = removeAll(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -200,15 +200,14 @@ func alterFiles(dir string) error {
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
|
||||||
case r == 3 && comps > 2 && (info.Mode().IsRegular() || rand.Float64() < 0.2):
|
case r == 4 && comps > 2 && (info.Mode().IsRegular() || rand.Float64() < 0.2):
|
||||||
rpath := filepath.Dir(path)
|
rpath := filepath.Dir(path)
|
||||||
if rand.Float64() < 0.2 {
|
if rand.Float64() < 0.2 {
|
||||||
for move := rand.Intn(comps - 1); move > 0; move-- {
|
for move := rand.Intn(comps - 1); move > 0; move-- {
|
||||||
rpath = filepath.Join(rpath, "..")
|
rpath = filepath.Join(rpath, "..")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
err = osutil.TryRename(path, filepath.Join(rpath, randomName()))
|
return osutil.TryRename(path, filepath.Join(rpath, randomName()))
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user