* Fix Spark _temporary cleanup and add issue #8285 regression test * Generalize empty folder cleanup for Spark temp artifacts * Revert synchronous folder pruning and add cleanup diagnostics * Add actionable empty-folder cleanup diagnostics * Fix Spark temp marker cleanup in async folder cleaner * Fix Spark temp cleanup with implicit directory markers * Keep explicit directory markers non-implicit * logging * more logs * Switch empty-folder cleanup to bucket policy * Seaweed-X-Amz-Allow-Empty-Folders * less logs * go vet * less logs * refactoring
53 lines
1.1 KiB
Go
53 lines
1.1 KiB
Go
//go:build linux || darwin || freebsd
|
|
// +build linux darwin freebsd
|
|
|
|
package command
|
|
|
|
import "testing"
|
|
|
|
func Test_bucketPathForMountRoot(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
mountRoot string
|
|
expected string
|
|
ok bool
|
|
}{
|
|
{
|
|
name: "bucket root mount",
|
|
mountRoot: "/buckets/test",
|
|
expected: "/buckets/test",
|
|
ok: true,
|
|
},
|
|
{
|
|
name: "bucket root with trailing slash",
|
|
mountRoot: "/buckets/test/",
|
|
expected: "/buckets/test",
|
|
ok: true,
|
|
},
|
|
{
|
|
name: "subdirectory mount",
|
|
mountRoot: "/buckets/test/data",
|
|
expected: "",
|
|
ok: false,
|
|
},
|
|
{
|
|
name: "non-bucket mount",
|
|
mountRoot: "/data/test",
|
|
expected: "",
|
|
ok: false,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
gotPath, gotOK := bucketPathForMountRoot(tt.mountRoot, "/buckets")
|
|
if gotOK != tt.ok {
|
|
t.Fatalf("expected ok=%v, got %v", tt.ok, gotOK)
|
|
}
|
|
if gotPath != tt.expected {
|
|
t.Fatalf("expected path %q, got %q", tt.expected, gotPath)
|
|
}
|
|
})
|
|
}
|
|
}
|