storagedriver/s3: Cleaning up tests

This commit is contained in:
Collin Shoop 2021-08-11 14:44:43 -04:00
parent e4af4dc3a6
commit 483ba26165

View File

@ -306,25 +306,6 @@ func TestDelete(t *testing.T) {
t.Fatalf("unexpected error creating driver with standard storage: %v", err) t.Fatalf("unexpected error creating driver with standard storage: %v", err)
} }
var objs = []string{
"/file1",
"/file1-2",
"/file1/2",
"/folder1/file1",
"/folder2/file1",
"/folder3/file1",
"/folder3/subfolder1/subfolder1/file1",
"/folder3/subfolder2/subfolder1/file1",
"/folder4/file1",
"/folder1-v2/file1",
"/folder1-v2/subfolder1/file1",
}
// objects to skip auto-created test case
var skipCase = map[string]bool{
// special case where deleting "/file1" also deletes "/file1/2" is tested explicitly
"/file1": true,
}
type errFn func(error) bool type errFn func(error) bool
type testCase struct { type testCase struct {
name string name string
@ -355,6 +336,20 @@ func TestDelete(t *testing.T) {
return false return false
} }
var objs = []string{
"/file1",
"/file1-2",
"/file1/2",
"/folder1/file1",
"/folder2/file1",
"/folder3/file1",
"/folder3/subfolder1/subfolder1/file1",
"/folder3/subfolder2/subfolder1/file1",
"/folder4/file1",
"/folder1-v2/file1",
"/folder1-v2/subfolder1/file1",
}
tcs := []testCase{ tcs := []testCase{
{ {
// special case where a given path is a file and has subpaths // special case where a given path is a file and has subpaths
@ -408,7 +403,12 @@ func TestDelete(t *testing.T) {
}, },
} }
// init a test case for each file // objects to skip auto-created test case
var skipCase = map[string]bool{
// special case where deleting "/file1" also deletes "/file1/2" is tested explicitly
"/file1": true,
}
// create a test case for each file
for _, path := range objs { for _, path := range objs {
if skipCase[path] { if skipCase[path] {
continue continue
@ -507,7 +507,7 @@ func TestDelete(t *testing.T) {
} }
if len(issues) > 0 { if len(issues) > 0 {
t.Fatalf(strings.Join(issues, "; ")) t.Fatalf(strings.Join(issues, "; \n\t"))
} }
}) })
} }