SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
package shell
import "testing"
// The ec and tier commands read an empty -collection as the collection with no
// name, unlike -collectionPattern, where empty means every collection.
func TestCompileCollectionPattern(t *testing.T) {
tests := []struct {
pattern string
matches []string
misses []string
}{
{pattern: "", matches: []string{""}, misses: []string{"pictures"}},
{pattern: CollectionDefault, matches: []string{""}, misses: []string{"pictures"}},
{pattern: "pictures", matches: []string{"pictures"}, misses: []string{"", "pictures-backup"}},
{pattern: "pictures,videos", matches: []string{"pictures", "videos"}, misses: []string{"", "clips"}},
{pattern: "pictures," + CollectionDefault, matches: []string{"pictures", ""}, misses: []string{"clips"}},
{pattern: "pictures*", matches: []string{"pictures", "pictures-backup"}, misses: []string{"clips"}},
{pattern: "^pictures", matches: []string{"pictures", "pictures-backup"}, misses: []string{"clips"}},
{pattern: "*", matches: []string{"", "pictures"}},
}
for _, tt := range tests {
matcher, err := compileCollectionPattern(tt.pattern)
if err != nil {
t.Fatalf("compileCollectionPattern(%q): %v", tt.pattern, err)
}
for _, collection := range tt.matches {
if !matcher.Matches(collection) {
t.Errorf("pattern %q should match collection %q", tt.pattern, collection)
}
}
for _, collection := range tt.misses {
if matcher.Matches(collection) {
t.Errorf("pattern %q should not match collection %q", tt.pattern, collection)
}
}
}
}