mirror of
https://github.com/distribution/distribution.git
synced 2025-08-20 07:45:33 +00:00
storagedriver/s3: refining tests
This commit is contained in:
parent
a08cc38c05
commit
c98c694d51
@ -96,32 +96,31 @@ func TestWalkFilesFileRemoved(t *testing.T) {
|
|||||||
func TestWalkFallback(t *testing.T) {
|
func TestWalkFallback(t *testing.T) {
|
||||||
d := &fileSystem{
|
d := &fileSystem{
|
||||||
fileset: map[string][]string{
|
fileset: map[string][]string{
|
||||||
"/": {"/a", "/b", "/c"},
|
"/": {"/file1", "/folder1", "/folder2"},
|
||||||
"/a": {"/a/1"},
|
"/folder1": {"/folder1/file1"},
|
||||||
"/b": {"/b/1", "/b/2"},
|
"/folder2": {"/folder2/file1"},
|
||||||
"/c": {"/c/1", "/c/2"},
|
|
||||||
"/a/1": {"/a/1/a", "/a/1/b"},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
var expected int
|
expected := []string{
|
||||||
for _, list := range d.fileset {
|
"/file1",
|
||||||
expected += len(list)
|
"/folder1", // return ErrSkipDir, skip anything under /folder1
|
||||||
|
"/folder1/file1",
|
||||||
|
"/folder2",
|
||||||
|
"/folder2/file1",
|
||||||
}
|
}
|
||||||
|
|
||||||
var walked []FileInfo
|
var walked []string
|
||||||
err := WalkFallback(context.Background(), d, "/", func(fileInfo FileInfo) error {
|
err := WalkFallback(context.Background(), d, "/", func(fileInfo FileInfo) error {
|
||||||
if fileInfo.IsDir() != d.isDir(fileInfo.Path()) {
|
if fileInfo.IsDir() != d.isDir(fileInfo.Path()) {
|
||||||
t.Fatalf("fileInfo isDir not matching file system: expected %t actual %t", d.isDir(fileInfo.Path()), fileInfo.IsDir())
|
t.Fatalf("fileInfo isDir not matching file system: expected %t actual %t", d.isDir(fileInfo.Path()), fileInfo.IsDir())
|
||||||
}
|
}
|
||||||
walked = append(walked, fileInfo)
|
walked = append(walked, fileInfo.Path())
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf(err.Error())
|
t.Fatalf(err.Error())
|
||||||
}
|
}
|
||||||
if expected != len(walked) {
|
compareWalked(t, expected, walked)
|
||||||
t.Fatalf("mismatch number of fileInfo walked, expected %d", expected)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Walk is expected to skip directory on ErrSkipDir
|
// Walk is expected to skip directory on ErrSkipDir
|
||||||
|
Loading…
Reference in New Issue
Block a user