seaweedfs/weed/filer/filer_conf_test.go

35 lines
734 B
Go
Raw Normal View History

2020-11-15 16:26:05 +08:00
package filer
import (
"testing"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"github.com/stretchr/testify/assert"
)
func TestFilerConf(t *testing.T) {
2020-11-16 06:06:03 +08:00
fc := NewFilerConf()
2020-11-15 16:26:05 +08:00
conf := &filer_pb.FilerConf{Locations: []*filer_pb.FilerConf_PathConf{
{
LocationPrefix: "/buckets/abc",
Collection: "abc",
},
{
LocationPrefix: "/buckets/abcd",
Collection: "abcd",
},
{
LocationPrefix: "/buckets/",
2020-11-27 03:22:30 +08:00
Replication: "001",
},
2020-11-15 16:26:05 +08:00
}}
fc.doLoadConf(conf)
assert.Equal(t, "abc", fc.MatchStorageRule("/buckets/abc/jasdf").Collection)
assert.Equal(t, "abcd", fc.MatchStorageRule("/buckets/abcd/jasdf").Collection)
assert.Equal(t, "001", fc.MatchStorageRule("/buckets/abc/jasdf").Replication)
2020-11-15 16:26:05 +08:00
}