fix tests

This commit is contained in:
Chris Lu
2021-08-04 00:31:06 -07:00
parent 42969c9c62
commit f6a9ad8001
3 changed files with 11 additions and 10 deletions

View File

@@ -87,19 +87,18 @@ func (rs *FilerRemoteStorage) FindMountDirectory(p util.FullPath) (mountDir util
}
func (rs *FilerRemoteStorage) FindRemoteStorageClient(p util.FullPath) (client remote_storage.RemoteStorageClient, remoteConf *filer_pb.RemoteConf, found bool) {
var storageLocation string
var storageLocation *filer_pb.RemoteStorageLocation
rs.rules.MatchPrefix([]byte(p), func(key []byte, value interface{}) bool {
storageLocation = value.(string)
storageLocation = value.(*filer_pb.RemoteStorageLocation)
return true
})
if storageLocation == "" {
if storageLocation == nil {
found = false
return
}
loc := remote_storage.ParseLocation(storageLocation)
return rs.GetRemoteStorageClient(loc.Name)
return rs.GetRemoteStorageClient(storageLocation.Name)
}
func (rs *FilerRemoteStorage) GetRemoteStorageClient(storageName string) (client remote_storage.RemoteStorageClient, remoteConf *filer_pb.RemoteConf, found bool) {

View File

@@ -14,7 +14,11 @@ func TestFilerRemoteStorage_FindRemoteStorageClient(t *testing.T) {
rs := NewFilerRemoteStorage()
rs.storageNameToConf[conf.Name] = conf
rs.mapDirectoryToRemoteStorage("/a/b/c", "s7")
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")