@@ -133,14 +133,18 @@ func TestTransformMasterVolumes(t *testing.T) {
133
133
134
134
}
135
135
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.
136
141
func TestTransformWorkerVolumes (t * testing.T ) {
137
142
type testCase struct {
138
143
name string
139
144
runtime * datav1alpha1.AlluxioRuntime
140
145
expect * Alluxio
141
146
expectErr bool
142
147
}
143
-
144
148
testCases := []testCase {
145
149
{
146
150
name : "all" ,
@@ -155,7 +159,8 @@ func TestTransformWorkerVolumes(t *testing.T) {
155
159
},
156
160
},
157
161
},
158
- }, Worker : datav1alpha1.AlluxioCompTemplateSpec {
162
+ },
163
+ Worker : datav1alpha1.AlluxioCompTemplateSpec {
159
164
VolumeMounts : []corev1.VolumeMount {
160
165
{
161
166
Name : "test" ,
@@ -176,7 +181,8 @@ func TestTransformWorkerVolumes(t *testing.T) {
176
181
},
177
182
},
178
183
},
179
- }, VolumeMounts : []corev1.VolumeMount {
184
+ },
185
+ VolumeMounts : []corev1.VolumeMount {
180
186
{
181
187
Name : "test" ,
182
188
MountPath : "/test" ,
@@ -185,7 +191,8 @@ func TestTransformWorkerVolumes(t *testing.T) {
185
191
},
186
192
},
187
193
expectErr : false ,
188
- }, {
194
+ },
195
+ {
189
196
name : "onlyVolumeMounts" ,
190
197
runtime : & datav1alpha1.AlluxioRuntime {
191
198
Spec : datav1alpha1.AlluxioRuntimeSpec {
@@ -210,7 +217,8 @@ func TestTransformWorkerVolumes(t *testing.T) {
210
217
},
211
218
},
212
219
},
213
- }, VolumeMounts : []corev1.VolumeMount {
220
+ },
221
+ VolumeMounts : []corev1.VolumeMount {
214
222
{
215
223
Name : "test" ,
216
224
MountPath : "/test" ,
@@ -221,11 +229,11 @@ func TestTransformWorkerVolumes(t *testing.T) {
221
229
expectErr : true ,
222
230
},
223
231
}
224
-
225
232
for _ , testCase := range testCases {
226
233
engine := & AlluxioEngine {}
227
234
got := & Alluxio {}
228
235
err := engine .transformWorkerVolumes (testCase .runtime , got )
236
+
229
237
if err != nil && ! testCase .expectErr {
230
238
t .Errorf ("Got unexpected error %v" , err )
231
239
}
@@ -237,9 +245,7 @@ func TestTransformWorkerVolumes(t *testing.T) {
237
245
if ! reflect .DeepEqual (got , testCase .expect ) {
238
246
t .Errorf ("want %v, got %v for testcase %s" , testCase .expect , got , testCase .name )
239
247
}
240
-
241
248
}
242
-
243
249
}
244
250
245
251
func TestTransformFuseVolumes (t * testing.T ) {
0 commit comments