mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 02:43:36 +00:00
rbd: move GetMappedID() to util package
This commit moves getMappedID() from rbd to util package since it is not rbd specific and exports it from there. Signed-off-by: Rakshith R <rar@redhat.com>
This commit is contained in:
@ -239,3 +239,55 @@ func validateMapping(t *testing.T, clusterID, rbdPoolID, cephFSPoolID string, ma
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestGetMappedID(t *testing.T) {
|
||||
t.Parallel()
|
||||
type args struct {
|
||||
key string
|
||||
value string
|
||||
id string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
name: "test for matching key",
|
||||
args: args{
|
||||
key: "cluster1",
|
||||
value: "cluster2",
|
||||
id: "cluster1",
|
||||
},
|
||||
expected: "cluster2",
|
||||
},
|
||||
{
|
||||
name: "test for matching value",
|
||||
args: args{
|
||||
key: "cluster1",
|
||||
value: "cluster2",
|
||||
id: "cluster2",
|
||||
},
|
||||
expected: "cluster1",
|
||||
},
|
||||
{
|
||||
name: "test for invalid match",
|
||||
args: args{
|
||||
key: "cluster1",
|
||||
value: "cluster2",
|
||||
id: "cluster3",
|
||||
},
|
||||
expected: "",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
val := GetMappedID(tt.args.key, tt.args.value, tt.args.id)
|
||||
if val != tt.expected {
|
||||
t.Errorf("getMappedID() got = %v, expected %v", val, tt.expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user