Skip to content

Commit 5a1fe40

Browse files
HumairAKmprahl
authored andcommitted
chore(backend): refactor driver tests (kubeflow#11777)
Signed-off-by: Humair Khan <[email protected]> (cherry picked from commit e9f5b5a)
1 parent b3eeeba commit 5a1fe40

File tree

1 file changed

+28
-43
lines changed

1 file changed

+28
-43
lines changed

backend/src/v2/driver/driver_test.go

Lines changed: 28 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -463,9 +463,7 @@ func Test_makeVolumeMountPatch(t *testing.T) {
463463
args args
464464
wantPath string
465465
wantName string
466-
wantErr bool
467466
inputParams map[string]*structpb.Value
468-
errMsg string
469467
}{
470468
{
471469
"pvc name: constant (deprecated)",
@@ -481,9 +479,7 @@ func Test_makeVolumeMountPatch(t *testing.T) {
481479
},
482480
"/mnt/path",
483481
"pvc-name",
484-
false,
485482
nil,
486-
"",
487483
},
488484
{
489485
"pvc name: constant parameter",
@@ -500,9 +496,7 @@ func Test_makeVolumeMountPatch(t *testing.T) {
500496
},
501497
"/mnt/path",
502498
"pvc-name",
503-
false,
504499
nil,
505-
"",
506500
},
507501
{
508502
"pvc name: component input parameter",
@@ -518,11 +512,9 @@ func Test_makeVolumeMountPatch(t *testing.T) {
518512
},
519513
"/mnt/path",
520514
"pvc-name",
521-
false,
522515
map[string]*structpb.Value{
523516
"param_1": structpb.NewStringValue("pvc-name"),
524517
},
525-
"",
526518
},
527519
}
528520

@@ -537,20 +529,13 @@ func Test_makeVolumeMountPatch(t *testing.T) {
537529
nil,
538530
tt.inputParams,
539531
)
540-
if tt.wantErr {
541-
assert.NotNil(t, err)
542-
assert.Nil(t, volumeMounts)
543-
assert.Nil(t, volumes)
544-
assert.Contains(t, err.Error(), tt.errMsg)
545-
} else {
546-
assert.Nil(t, err)
547-
assert.Equal(t, 1, len(volumeMounts))
548-
assert.Equal(t, 1, len(volumes))
549-
assert.Equal(t, volumeMounts[0].MountPath, tt.wantPath)
550-
assert.Equal(t, volumeMounts[0].Name, tt.wantName)
551-
assert.Equal(t, volumes[0].Name, tt.wantName)
552-
assert.Equal(t, volumes[0].PersistentVolumeClaim.ClaimName, tt.wantName)
553-
}
532+
assert.Nil(t, err)
533+
assert.Equal(t, 1, len(volumeMounts))
534+
assert.Equal(t, 1, len(volumes))
535+
assert.Equal(t, volumeMounts[0].MountPath, tt.wantPath)
536+
assert.Equal(t, volumeMounts[0].Name, tt.wantName)
537+
assert.Equal(t, volumes[0].Name, tt.wantName)
538+
assert.Equal(t, volumes[0].PersistentVolumeClaim.ClaimName, tt.wantName)
554539
})
555540
}
556541
}
@@ -1071,9 +1056,9 @@ func Test_extendPodSpecPatch_Secret(t *testing.T) {
10711056
Name: "SECRET_VAR",
10721057
ValueFrom: &k8score.EnvVarSource{
10731058
SecretKeyRef: &k8score.SecretKeySelector{
1074-
k8score.LocalObjectReference{Name: "my-secret"},
1075-
"password",
1076-
nil,
1059+
LocalObjectReference: k8score.LocalObjectReference{Name: "my-secret"},
1060+
Key: "password",
1061+
Optional: nil,
10771062
},
10781063
},
10791064
},
@@ -1115,9 +1100,9 @@ func Test_extendPodSpecPatch_Secret(t *testing.T) {
11151100
Name: "SECRET_VAR",
11161101
ValueFrom: &k8score.EnvVarSource{
11171102
SecretKeyRef: &k8score.SecretKeySelector{
1118-
k8score.LocalObjectReference{Name: "my-secret"},
1119-
"password",
1120-
nil,
1103+
LocalObjectReference: k8score.LocalObjectReference{Name: "my-secret"},
1104+
Key: "password",
1105+
Optional: nil,
11211106
},
11221107
},
11231108
},
@@ -1158,9 +1143,9 @@ func Test_extendPodSpecPatch_Secret(t *testing.T) {
11581143
Name: "SECRET_VAR",
11591144
ValueFrom: &k8score.EnvVarSource{
11601145
SecretKeyRef: &k8score.SecretKeySelector{
1161-
k8score.LocalObjectReference{Name: "secret-name"},
1162-
"password",
1163-
nil,
1146+
LocalObjectReference: k8score.LocalObjectReference{Name: "secret-name"},
1147+
Key: "password",
1148+
Optional: nil,
11641149
},
11651150
},
11661151
},
@@ -1472,9 +1457,9 @@ func Test_extendPodSpecPatch_ConfigMap(t *testing.T) {
14721457
Name: "CONFIG_MAP_VAR",
14731458
ValueFrom: &k8score.EnvVarSource{
14741459
ConfigMapKeyRef: &k8score.ConfigMapKeySelector{
1475-
k8score.LocalObjectReference{Name: "my-cm"},
1476-
"foo",
1477-
nil,
1460+
LocalObjectReference: k8score.LocalObjectReference{Name: "my-cm"},
1461+
Key: "foo",
1462+
Optional: nil,
14781463
},
14791464
},
14801465
},
@@ -1516,9 +1501,9 @@ func Test_extendPodSpecPatch_ConfigMap(t *testing.T) {
15161501
Name: "CONFIG_MAP_VAR",
15171502
ValueFrom: &k8score.EnvVarSource{
15181503
ConfigMapKeyRef: &k8score.ConfigMapKeySelector{
1519-
k8score.LocalObjectReference{Name: "my-cm"},
1520-
"foo",
1521-
nil,
1504+
LocalObjectReference: k8score.LocalObjectReference{Name: "my-cm"},
1505+
Key: "foo",
1506+
Optional: nil,
15221507
},
15231508
},
15241509
},
@@ -1560,9 +1545,9 @@ func Test_extendPodSpecPatch_ConfigMap(t *testing.T) {
15601545
Name: "CONFIG_MAP_VAR",
15611546
ValueFrom: &k8score.EnvVarSource{
15621547
ConfigMapKeyRef: &k8score.ConfigMapKeySelector{
1563-
k8score.LocalObjectReference{Name: "cm-name"},
1564-
"foo",
1565-
nil,
1548+
LocalObjectReference: k8score.LocalObjectReference{Name: "cm-name"},
1549+
Key: "foo",
1550+
Optional: nil,
15661551
},
15671552
},
15681553
},
@@ -2173,9 +2158,9 @@ func Test_extendPodSpecPatch_FieldPathAsEnv(t *testing.T) {
21732158
Name: "SECRET_VAR",
21742159
ValueFrom: &k8score.EnvVarSource{
21752160
SecretKeyRef: &k8score.SecretKeySelector{
2176-
k8score.LocalObjectReference{Name: "my-secret"},
2177-
"password",
2178-
nil,
2161+
LocalObjectReference: k8score.LocalObjectReference{Name: "my-secret"},
2162+
Key: "password",
2163+
Optional: nil,
21792164
},
21802165
},
21812166
},

0 commit comments

Comments
 (0)