You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.1 KiB

4 years ago
  1. package filer
  2. import (
  3. "testing"
  4. "github.com/seaweedfs/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. LocationPrefix: "/buckets",
  24. ReadOnly: false,
  25. },
  26. {
  27. LocationPrefix: "/buckets/xxx",
  28. ReadOnly: true,
  29. },
  30. {
  31. LocationPrefix: "/buckets/xxx/yyy",
  32. ReadOnly: false,
  33. },
  34. }}
  35. fc.doLoadConf(conf)
  36. assert.Equal(t, "abc", fc.MatchStorageRule("/buckets/abc/jasdf").Collection)
  37. assert.Equal(t, "abcd", fc.MatchStorageRule("/buckets/abcd/jasdf").Collection)
  38. assert.Equal(t, "001", fc.MatchStorageRule("/buckets/abc/jasdf").Replication)
  39. assert.Equal(t, true, fc.MatchStorageRule("/buckets/xxx/yyy/zzz").ReadOnly)
  40. assert.Equal(t, false, fc.MatchStorageRule("/buckets/other").ReadOnly)
  41. }