Skip to content

Commit

Permalink
Add Fuse container sidecar test, To #37688693
Browse files Browse the repository at this point in the history
Signed-off-by: cheyang <[email protected]>
  • Loading branch information
cheyang committed Feb 25, 2022
1 parent 48d9a0a commit 9f64c07
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions pkg/utils/volumes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,51 @@ func TestTrimVolumes(t *testing.T) {
}

func TestTrimVolumeMounts(t *testing.T) {
testCases := map[string]struct {
volumeMounts []corev1.VolumeMount
names []string
wants []string
}{
"no exclude": {
volumeMounts: []corev1.VolumeMount{
{
Name: "test-1",
},
{
Name: "fuse-device",
},
{
Name: "jindofs-fuse-mount",
},
},
names: []string{"datavolumeMount-", "cache-dir", "mem", "ssd", "hdd"},
wants: []string{"test-1", "fuse-device", "jindofs-fuse-mount"},
}, "exclude": {
volumeMounts: []corev1.VolumeMount{
{
Name: "datavolumeMount-1",
},
{
Name: "fuse-device",
},
{
Name: "jindofs-fuse-mount",
},
},
names: []string{"datavolumeMount-", "cache-dir", "mem", "ssd", "hdd"},
wants: []string{"fuse-device", "jindofs-fuse-mount"},
},
}

for name, testCase := range testCases {
got := TrimVolumeMounts(testCase.volumeMounts, testCase.names)
gotNames := []string{}
for _, name := range got {
gotNames = append(gotNames, name.Name)
}

if !reflect.DeepEqual(gotNames, testCase.wants) {
t.Errorf("%s check failure, want:%v, got:%v", name, testCase.names, gotNames)
}
}
}

0 comments on commit 9f64c07

Please sign in to comment.