@@ -17,166 +17,89 @@ limitations under the License.
1717package base
1818
1919import (
20- "testing"
21-
2220 "github.com/fluid-cloudnative/fluid/pkg/common"
2321 "github.com/fluid-cloudnative/fluid/pkg/utils"
22+ . "github.com/onsi/ginkgo/v2"
23+ . "github.com/onsi/gomega"
2424)
2525
26- func TestGetStorageLabelName (t * testing.T ) {
27- tests := []struct {
28- info RuntimeInfo
29- expectedResult string
30- }{
31- {
32- info : RuntimeInfo {
26+ var _ = Describe ("Label Functions" , func () {
27+ Describe ("GetStorageLabelName" , func () {
28+ It ("should return correct storage label name" , func () {
29+ info := RuntimeInfo {
3330 name : "spark" ,
3431 namespace : "default" ,
3532 runtimeType : common .AlluxioRuntime ,
36- },
37-
38- expectedResult : "fluid.io/s-h-alluxio-m-default-spark" ,
39- },
40- }
41-
42- for _ , test := range tests {
43- result := utils .GetStorageLabelName (common .HumanReadType , common .MemoryStorageType , test .info .runtimeType , test .info .namespace , test .info .name , "" )
44- if test .expectedResult != result {
45- t .Errorf ("check failure, expected %s, get %s" , test .expectedResult , result )
46- }
47- }
48- }
49-
50- func TestGetLabelNameForMemory (t * testing.T ) {
51- tests := []struct {
52- info RuntimeInfo
53- expectResult string
54- }{
55- {
56- info : RuntimeInfo {
33+ }
34+ result := utils .GetStorageLabelName (common .HumanReadType , common .MemoryStorageType , info .runtimeType , info .namespace , info .name , "" )
35+ Expect (result ).To (Equal ("fluid.io/s-h-alluxio-m-default-spark" ))
36+ })
37+ })
38+
39+ Describe ("GetLabelNameForMemory" , func () {
40+ It ("should return correct memory label name" , func () {
41+ info := RuntimeInfo {
5742 name : "spark" ,
5843 namespace : "default" ,
5944 runtimeType : common .AlluxioRuntime ,
60- },
61- expectResult : "fluid.io/s-h-alluxio-m-default-spark" ,
62- },
63- }
64-
65- for _ , test := range tests {
66- result := test .info .GetLabelNameForMemory ()
67- if test .expectResult != result {
68- t .Errorf ("check failure, expected %s, get %s" , test .expectResult , result )
69- }
70- }
71- }
72-
73- func TestGetLabelNameForDisk (t * testing.T ) {
74- tests := []struct {
75- info RuntimeInfo
76- expectResult string
77- }{
78- {
79- info : RuntimeInfo {
45+ }
46+ result := info .GetLabelNameForMemory ()
47+ Expect (result ).To (Equal ("fluid.io/s-h-alluxio-m-default-spark" ))
48+ })
49+ })
50+
51+ Describe ("GetLabelNameForDisk" , func () {
52+ It ("should return correct disk label name" , func () {
53+ info := RuntimeInfo {
8054 name : "spark" ,
8155 namespace : "default" ,
8256 runtimeType : common .AlluxioRuntime ,
83- },
84- expectResult : "fluid.io/s-h-alluxio-d-default-spark" ,
85- },
86- }
87-
88- for _ , test := range tests {
89- result := test .info .GetLabelNameForDisk ()
90- if result != test .expectResult {
91- t .Errorf ("check failure, expected %s, get %s" , test .expectResult , result )
92- }
93- }
94- }
95-
96- func TestGetLabelNameForTotal (t * testing.T ) {
97- tests := []struct {
98- info RuntimeInfo
99- expectResult string
100- }{
101- {
102- info : RuntimeInfo {
57+ }
58+ result := info .GetLabelNameForDisk ()
59+ Expect (result ).To (Equal ("fluid.io/s-h-alluxio-d-default-spark" ))
60+ })
61+ })
62+
63+ Describe ("GetLabelNameForTotal" , func () {
64+ It ("should return correct total label name" , func () {
65+ info := RuntimeInfo {
10366 name : "spark" ,
10467 namespace : "default" ,
10568 runtimeType : common .AlluxioRuntime ,
106- },
107- expectResult : "fluid.io/s-h-alluxio-t-default-spark" ,
108- },
109- }
110-
111- for _ , test := range tests {
112- result := test .info .GetLabelNameForTotal ()
113- if result != test .expectResult {
114- t .Errorf ("check failure, expected %s, get %s" , test .expectResult , result )
115- }
116- }
117- }
118-
119- func TestGetCommonLabelName (t * testing.T ) {
120- tests := []struct {
121- info RuntimeInfo
122- expectResult string
123- }{
124- {
125- info : RuntimeInfo {
69+ }
70+ result := info .GetLabelNameForTotal ()
71+ Expect (result ).To (Equal ("fluid.io/s-h-alluxio-t-default-spark" ))
72+ })
73+ })
74+
75+ Describe ("GetCommonLabelName" , func () {
76+ It ("should return correct common label name" , func () {
77+ info := RuntimeInfo {
12678 name : "spark" ,
12779 namespace : "default" ,
128- },
129- expectResult : "fluid.io/s-default-spark" ,
130- },
131- }
132-
133- for _ , test := range tests {
134- result := test .info .GetCommonLabelName ()
135- if result != test .expectResult {
136- t .Errorf ("check failure, expected %s, get %s" , test .expectResult , result )
137- }
138- }
139- }
140-
141- func TestGetRuntimeLabelName (t * testing.T ) {
142- tests := []struct {
143- info RuntimeInfo
144- expectResult string
145- }{
146- {
147- info : RuntimeInfo {
80+ }
81+ result := info .GetCommonLabelName ()
82+ Expect (result ).To (Equal ("fluid.io/s-default-spark" ))
83+ })
84+ })
85+
86+ Describe ("GetRuntimeLabelName" , func () {
87+ It ("should return correct runtime label name" , func () {
88+ info := RuntimeInfo {
14889 name : "spark" ,
14990 namespace : "default" ,
15091 runtimeType : common .AlluxioRuntime ,
151- },
152- expectResult : "fluid.io/s-alluxio-default-spark" ,
153- },
154- }
155-
156- for _ , test := range tests {
157- result := test .info .GetRuntimeLabelName ()
158- if result != test .expectResult {
159- t .Errorf ("check failure, expected %s, get %s" , test .expectResult , result )
160- }
161- }
162- }
163-
164- func TestGetDatasetNumLabelName (t * testing.T ) {
165-
166- tests := []struct {
167- info RuntimeInfo
168- expectedResult string
169- }{
170- {
171- info : RuntimeInfo {},
172- expectedResult : common .LabelAnnotationDatasetNum ,
173- },
174- }
175- for _ , test := range tests {
176- result := test .info .GetDatasetNumLabelName ()
177- if result != test .expectedResult {
178- t .Errorf ("check failure, expected %s, get %s" , test .expectedResult , result )
179- }
180- }
181-
182- }
92+ }
93+ result := info .GetRuntimeLabelName ()
94+ Expect (result ).To (Equal ("fluid.io/s-alluxio-default-spark" ))
95+ })
96+ })
97+
98+ Describe ("GetDatasetNumLabelName" , func () {
99+ It ("should return dataset num label name" , func () {
100+ info := RuntimeInfo {}
101+ result := info .GetDatasetNumLabelName ()
102+ Expect (result ).To (Equal (common .LabelAnnotationDatasetNum ))
103+ })
104+ })
105+ })
0 commit comments