Skip to content

Commit

Permalink
add a test case (fluid-cloudnative#1036)
Browse files Browse the repository at this point in the history
Signed-off-by: yangyuliufeng <[email protected]>
  • Loading branch information
yangyuliufeng authored Oct 13, 2021
1 parent 90ed32d commit f8adea7
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions pkg/ddc/base/pv_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package base

import (
datav1alpha1 "github.com/fluid-cloudnative/fluid/api/v1alpha1"
"testing"
)

func TestGetPersistentVolumeName(t *testing.T) {
var testCases = []struct {
runtimeName string
runtimeNamespace string
isDeprecatedPVName bool
expectedPVName string
}{
{
runtimeName: "spark",
runtimeNamespace: "fluid",
isDeprecatedPVName: false,
expectedPVName: "fluid-spark",
},
{
runtimeName: "hadoop",
runtimeNamespace: "test",
isDeprecatedPVName: false,
expectedPVName: "test-hadoop",
},
{
runtimeName: "hbase",
runtimeNamespace: "fluid",
isDeprecatedPVName: true,
expectedPVName: "hbase",
},

}
for _, testCase := range testCases {
runtimeInfo, err := BuildRuntimeInfo(testCase.runtimeName, testCase.runtimeNamespace, "alluxio", datav1alpha1.TieredStore{})
if err != nil {
t.Errorf("fail to create the runtimeInfo with error %v", err)
}
runtimeInfo.SetDeprecatedPVName(testCase.isDeprecatedPVName)
result := runtimeInfo.GetPersistentVolumeName()
if result != testCase.expectedPVName {
t.Errorf("get failure, expected %s, get %s", testCase.expectedPVName, result)
}
}
}

0 comments on commit f8adea7

Please sign in to comment.