load filer conf and match by prefix

This commit is contained in:
Chris Lu
2020-11-15 00:26:05 -08:00
parent 68043cfcac
commit 0a406f652e
5 changed files with 100 additions and 4 deletions

View File

@@ -0,0 +1,31 @@
package filer
import (
"testing"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"github.com/stretchr/testify/assert"
"github.com/viant/ptrie"
)
func TestFilerConf(t *testing.T) {
fc := &FilerConf{
rules: ptrie.New(),
}
conf := &filer_pb.FilerConf{Locations: []*filer_pb.FilerConf_PathConf{
{
LocationPrefix: "/buckets/abc",
Collection: "abc",
},
{
LocationPrefix: "/buckets/abcd",
Collection: "abcd",
},
}}
fc.doLoadConf(conf)
assert.Equal(t, "abc", fc.MatchStorageRule("/buckets/abc/jasdf").Collection)
assert.Equal(t, "abcd", fc.MatchStorageRule("/buckets/abcd/jasdf").Collection)
}