remote_storage_test.go 940 B

12345678910111213141516171819202122232425262728293031323334
  1. package filer
  2. import (
  3. "github.com/chrislusf/seaweedfs/weed/pb/remote_pb"
  4. "github.com/stretchr/testify/assert"
  5. "testing"
  6. )
  7. func TestFilerRemoteStorage_FindRemoteStorageClient(t *testing.T) {
  8. conf := &remote_pb.RemoteConf{
  9. Name: "s7",
  10. Type: "s3",
  11. }
  12. rs := NewFilerRemoteStorage()
  13. rs.storageNameToConf[conf.Name] = conf
  14. rs.mapDirectoryToRemoteStorage("/a/b/c", &remote_pb.RemoteStorageLocation{
  15. Name: "s7",
  16. Bucket: "some",
  17. Path: "/dir",
  18. })
  19. _, _, found := rs.FindRemoteStorageClient("/a/b/c/d/e/f")
  20. assert.Equal(t, true, found, "find storage client")
  21. _, _, found2 := rs.FindRemoteStorageClient("/a/b")
  22. assert.Equal(t, false, found2, "should not find storage client")
  23. _, _, found3 := rs.FindRemoteStorageClient("/a/b/c")
  24. assert.Equal(t, false, found3, "should not find storage client")
  25. _, _, found4 := rs.FindRemoteStorageClient("/a/b/cc")
  26. assert.Equal(t, false, found4, "should not find storage client")
  27. }