aboutsummaryrefslogtreecommitdiff
path: root/weed/filer/filer_remote_storage_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'weed/filer/filer_remote_storage_test.go')
-rw-r--r--weed/filer/filer_remote_storage_test.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/weed/filer/filer_remote_storage_test.go b/weed/filer/filer_remote_storage_test.go
new file mode 100644
index 000000000..427cd5a8a
--- /dev/null
+++ b/weed/filer/filer_remote_storage_test.go
@@ -0,0 +1,34 @@
+package filer
+
+import (
+ "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
+ "github.com/stretchr/testify/assert"
+ "testing"
+)
+
+func TestFilerRemoteStorage_FindRemoteStorageClient(t *testing.T) {
+ conf := &filer_pb.RemoteConf{
+ Name: "s7",
+ Type: "s3",
+ }
+ rs := NewFilerRemoteStorage()
+ rs.storageNameToConf[conf.Name] = conf
+
+ rs.mapDirectoryToRemoteStorage("/a/b/c", &filer_pb.RemoteStorageLocation{
+ Name: "s7",
+ Bucket: "some",
+ Path: "/dir",
+ })
+
+ _, _, found := rs.FindRemoteStorageClient("/a/b/c/d/e/f")
+ assert.Equal(t, true, found, "find storage client")
+
+ _, _, found2 := rs.FindRemoteStorageClient("/a/b")
+ assert.Equal(t, false, found2, "should not find storage client")
+
+ _, _, found3 := rs.FindRemoteStorageClient("/a/b/c")
+ assert.Equal(t, false, found3, "should not find storage client")
+
+ _, _, found4 := rs.FindRemoteStorageClient("/a/b/cc")
+ assert.Equal(t, false, found4, "should not find storage client")
+} \ No newline at end of file