Merge pull request #832 from BrianBland/ng-storagedriver-tests

Updates storagedriver tests to better test directory trees
This commit is contained in:
Stephen Day
2014-12-09 21:01:40 -08:00
6 changed files with 217 additions and 91 deletions

View File

@@ -11,7 +11,7 @@ import (
var (
errExists = fmt.Errorf("exists")
errNotExists = fmt.Errorf("exists")
errNotExists = fmt.Errorf("notexists")
errIsNotDir = fmt.Errorf("notdir")
errIsDir = fmt.Errorf("isdir")
)
@@ -139,9 +139,7 @@ func (d *dir) mkfile(p string) (*file, error) {
// mkdirs creates any missing directory entries in p and returns the result.
func (d *dir) mkdirs(p string) (*dir, error) {
if p == "" {
p = "/"
}
p = normalize(p)
n := d.find(p)
@@ -210,7 +208,7 @@ func (d *dir) move(src, dst string) error {
srcDirname, srcFilename := path.Split(src)
sp := d.find(srcDirname)
if sp.path() != srcDirname {
if normalize(srcDirname) != normalize(sp.path()) {
return errNotExists
}
@@ -237,7 +235,7 @@ func (d *dir) delete(p string) error {
dirname, filename := path.Split(p)
parent := d.find(dirname)
if dirname != parent.path() {
if normalize(dirname) != normalize(parent.path()) {
return errNotExists
}
@@ -328,3 +326,7 @@ func (c *common) path() string {
func (c *common) modtime() time.Time {
return c.mod
}
func normalize(p string) string {
return "/" + strings.Trim(p, "/")
}