filer_conf_test.go 731 B

12345678910111213141516171819202122232425262728293031323334
  1. package filer
  2. import (
  3. "testing"
  4. "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
  5. "github.com/stretchr/testify/assert"
  6. )
  7. func TestFilerConf(t *testing.T) {
  8. fc := NewFilerConf()
  9. conf := &filer_pb.FilerConf{Locations: []*filer_pb.FilerConf_PathConf{
  10. {
  11. LocationPrefix: "/buckets/abc",
  12. Collection: "abc",
  13. },
  14. {
  15. LocationPrefix: "/buckets/abcd",
  16. Collection: "abcd",
  17. },
  18. {
  19. LocationPrefix: "/buckets/",
  20. Replication: "001",
  21. },
  22. }}
  23. fc.doLoadConf(conf)
  24. assert.Equal(t, "abc", fc.MatchStorageRule("/buckets/abc/jasdf").Collection)
  25. assert.Equal(t, "abcd", fc.MatchStorageRule("/buckets/abcd/jasdf").Collection)
  26. assert.Equal(t, "001", fc.MatchStorageRule("/buckets/abc/jasdf").Replication)
  27. }