seaweedfs/weed/filer2/filer_test.go

31 lines
605 B
Go
Raw Normal View History

2018-05-11 17:20:15 +08:00
package filer2
import (
"testing"
"path/filepath"
"fmt"
)
func TestRecursion(t *testing.T) {
fullPath := "/home/chris/some/file/abc.jpg"
expected := []string{
"/", "home",
2018-05-11 17:27:57 +08:00
"/home", "chris",
"/home/chris", "some",
"/home/chris/some", "file",
2018-05-11 17:20:15 +08:00
}
dir, _ := filepath.Split(fullPath)
i := 0
2018-05-11 17:27:57 +08:00
recursivelyEnsureDirectory(dir, func(parent, name string) error {
2018-05-11 17:20:15 +08:00
if parent != expected[i] || name != expected[i+1] {
t.Errorf("recursive directory is wrong! parent=%s dirName=%s", parent, name)
}
fmt.Printf("processing folder %s \t parent=%s\n", name, parent)
i += 2
return nil
})
}