2021-07-27 08:16:28 +00:00
|
|
|
package filer
|
|
|
|
|
|
|
|
import (
|
2021-08-27 00:33:57 +00:00
|
|
|
"github.com/chrislusf/seaweedfs/weed/pb/remote_pb"
|
2021-07-27 08:16:28 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestFilerRemoteStorage_FindRemoteStorageClient(t *testing.T) {
|
2021-08-26 22:18:34 +00:00
|
|
|
conf := &remote_pb.RemoteConf{
|
2021-07-27 08:16:28 +00:00
|
|
|
Name: "s7",
|
|
|
|
Type: "s3",
|
|
|
|
}
|
|
|
|
rs := NewFilerRemoteStorage()
|
|
|
|
rs.storageNameToConf[conf.Name] = conf
|
|
|
|
|
2021-08-26 22:18:34 +00:00
|
|
|
rs.mapDirectoryToRemoteStorage("/a/b/c", &remote_pb.RemoteStorageLocation{
|
2021-08-04 07:31:06 +00:00
|
|
|
Name: "s7",
|
|
|
|
Bucket: "some",
|
|
|
|
Path: "/dir",
|
|
|
|
})
|
2021-07-27 08:16:28 +00:00
|
|
|
|
2021-07-29 05:43:12 +00:00
|
|
|
_, _, found := rs.FindRemoteStorageClient("/a/b/c/d/e/f")
|
2021-07-27 08:16:28 +00:00
|
|
|
assert.Equal(t, true, found, "find storage client")
|
|
|
|
|
2021-07-29 05:43:12 +00:00
|
|
|
_, _, found2 := rs.FindRemoteStorageClient("/a/b")
|
2021-07-27 08:16:28 +00:00
|
|
|
assert.Equal(t, false, found2, "should not find storage client")
|
|
|
|
|
2021-07-29 05:43:12 +00:00
|
|
|
_, _, found3 := rs.FindRemoteStorageClient("/a/b/c")
|
2021-07-27 08:16:28 +00:00
|
|
|
assert.Equal(t, false, found3, "should not find storage client")
|
|
|
|
|
2021-07-29 05:43:12 +00:00
|
|
|
_, _, found4 := rs.FindRemoteStorageClient("/a/b/cc")
|
2021-07-27 08:16:28 +00:00
|
|
|
assert.Equal(t, false, found4, "should not find storage client")
|
2021-08-09 05:30:36 +00:00
|
|
|
}
|