Skip to content

Commit 4941630

Browse files
SirilawSirilawcheyang
authored
This PR is to add Comments to TestTransformWorkerValumes in pkg/ddc/alluxio/transform_volumes_test.go (#4556)
* Add Comments to TestTransformWorkerValumes in pkg/ddc/alluxio/transform_volumes_test.go Signed-off-by: Sirilaw <480469140@qq.com> * Add Comments to TestTransformWorkerValumes in pkg/ddc/alluxio/transform_volumes_test.go Signed-off-by: Sirilaw <480469140@qq.com> * Gofmt transform_volumes_test.go Signed-off-by: cheyang <cheyang@163.com> --------- Signed-off-by: Sirilaw <480469140@qq.com> Signed-off-by: cheyang <cheyang@163.com> Co-authored-by: Sirilaw <480469140@qq.com> Co-authored-by: cheyang <cheyang@163.com>
1 parent b56a93e commit 4941630

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

pkg/ddc/alluxio/transform_volumes_test.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,18 @@ func TestTransformMasterVolumes(t *testing.T) {
133133

134134
}
135135

136+
// TestTransformWorkerVolumes is a unit test function that tests the transformWorkerVolumes method of the AlluxioEngine.
137+
// It defines a series of test cases to verify the correctness of volume and volume mount transformations for the Alluxio worker.
138+
// Each test case includes an input AlluxioRuntime object and an expected Alluxio object, along with a flag to indicate if an error is expected.
139+
// The function iterates through each test case, applies the transformWorkerVolumes method, and checks if the output matches the expected result.
140+
// If an error occurs and it is not expected, or if the output does not match the expected result, the test fails with an appropriate error message.
136141
func TestTransformWorkerVolumes(t *testing.T) {
137142
type testCase struct {
138143
name string
139144
runtime *datav1alpha1.AlluxioRuntime
140145
expect *Alluxio
141146
expectErr bool
142147
}
143-
144148
testCases := []testCase{
145149
{
146150
name: "all",
@@ -155,7 +159,8 @@ func TestTransformWorkerVolumes(t *testing.T) {
155159
},
156160
},
157161
},
158-
}, Worker: datav1alpha1.AlluxioCompTemplateSpec{
162+
},
163+
Worker: datav1alpha1.AlluxioCompTemplateSpec{
159164
VolumeMounts: []corev1.VolumeMount{
160165
{
161166
Name: "test",
@@ -176,7 +181,8 @@ func TestTransformWorkerVolumes(t *testing.T) {
176181
},
177182
},
178183
},
179-
}, VolumeMounts: []corev1.VolumeMount{
184+
},
185+
VolumeMounts: []corev1.VolumeMount{
180186
{
181187
Name: "test",
182188
MountPath: "/test",
@@ -185,7 +191,8 @@ func TestTransformWorkerVolumes(t *testing.T) {
185191
},
186192
},
187193
expectErr: false,
188-
}, {
194+
},
195+
{
189196
name: "onlyVolumeMounts",
190197
runtime: &datav1alpha1.AlluxioRuntime{
191198
Spec: datav1alpha1.AlluxioRuntimeSpec{
@@ -210,7 +217,8 @@ func TestTransformWorkerVolumes(t *testing.T) {
210217
},
211218
},
212219
},
213-
}, VolumeMounts: []corev1.VolumeMount{
220+
},
221+
VolumeMounts: []corev1.VolumeMount{
214222
{
215223
Name: "test",
216224
MountPath: "/test",
@@ -221,11 +229,11 @@ func TestTransformWorkerVolumes(t *testing.T) {
221229
expectErr: true,
222230
},
223231
}
224-
225232
for _, testCase := range testCases {
226233
engine := &AlluxioEngine{}
227234
got := &Alluxio{}
228235
err := engine.transformWorkerVolumes(testCase.runtime, got)
236+
229237
if err != nil && !testCase.expectErr {
230238
t.Errorf("Got unexpected error %v", err)
231239
}
@@ -237,9 +245,7 @@ func TestTransformWorkerVolumes(t *testing.T) {
237245
if !reflect.DeepEqual(got, testCase.expect) {
238246
t.Errorf("want %v, got %v for testcase %s", testCase.expect, got, testCase.name)
239247
}
240-
241248
}
242-
243249
}
244250

245251
func TestTransformFuseVolumes(t *testing.T) {

0 commit comments

Comments
 (0)