Merge pull request #124740 from bells17/use-sets-set-string

[pkg/volume] Changed to use sets.Set[string] instead of sets.String
This commit is contained in:
Kubernetes Prow Robot
2024-05-31 05:32:15 -07:00
committed by GitHub
10 changed files with 66 additions and 66 deletions

View File

@@ -641,8 +641,8 @@ func TestGetPodVolumeNames(t *testing.T) {
tests := []struct {
name string
pod *v1.Pod
expectedMounts sets.String
expectedDevices sets.String
expectedMounts sets.Set[string]
expectedDevices sets.Set[string]
expectedSELinuxContexts map[string][]*v1.SELinuxOptions
}{
{
@@ -650,8 +650,8 @@ func TestGetPodVolumeNames(t *testing.T) {
pod: &v1.Pod{
Spec: v1.PodSpec{},
},
expectedMounts: sets.NewString(),
expectedDevices: sets.NewString(),
expectedMounts: sets.New[string](),
expectedDevices: sets.New[string](),
},
{
name: "pod with volumes",
@@ -694,8 +694,8 @@ func TestGetPodVolumeNames(t *testing.T) {
},
},
},
expectedMounts: sets.NewString("vol1", "vol2"),
expectedDevices: sets.NewString("vol3", "vol4"),
expectedMounts: sets.New[string]("vol1", "vol2"),
expectedDevices: sets.New[string]("vol3", "vol4"),
},
{
name: "pod with init containers",
@@ -738,8 +738,8 @@ func TestGetPodVolumeNames(t *testing.T) {
},
},
},
expectedMounts: sets.NewString("vol1", "vol2"),
expectedDevices: sets.NewString("vol3", "vol4"),
expectedMounts: sets.New[string]("vol1", "vol2"),
expectedDevices: sets.New[string]("vol3", "vol4"),
},
{
name: "pod with multiple containers",
@@ -797,8 +797,8 @@ func TestGetPodVolumeNames(t *testing.T) {
},
},
},
expectedMounts: sets.NewString("vol1", "vol3"),
expectedDevices: sets.NewString("vol2", "vol4"),
expectedMounts: sets.New[string]("vol1", "vol3"),
expectedDevices: sets.New[string]("vol2", "vol4"),
},
{
name: "pod with ephemeral containers",
@@ -839,8 +839,8 @@ func TestGetPodVolumeNames(t *testing.T) {
},
},
},
expectedMounts: sets.NewString("vol1", "vol2"),
expectedDevices: sets.NewString(),
expectedMounts: sets.New[string]("vol1", "vol2"),
expectedDevices: sets.New[string](),
},
{
name: "pod with SELinuxOptions",
@@ -912,7 +912,7 @@ func TestGetPodVolumeNames(t *testing.T) {
},
},
},
expectedMounts: sets.NewString("vol1", "vol2", "vol3"),
expectedMounts: sets.New[string]("vol1", "vol2", "vol3"),
expectedSELinuxContexts: map[string][]*v1.SELinuxOptions{
"vol1": {
{
@@ -948,10 +948,10 @@ func TestGetPodVolumeNames(t *testing.T) {
t.Run(test.name, func(t *testing.T) {
mounts, devices, contexts := GetPodVolumeNames(test.pod)
if !mounts.Equal(test.expectedMounts) {
t.Errorf("Expected mounts: %q, got %q", mounts.List(), test.expectedMounts.List())
t.Errorf("Expected mounts: %q, got %q", sets.List[string](mounts), sets.List[string](test.expectedMounts))
}
if !devices.Equal(test.expectedDevices) {
t.Errorf("Expected devices: %q, got %q", devices.List(), test.expectedDevices.List())
t.Errorf("Expected devices: %q, got %q", sets.List[string](devices), sets.List[string](test.expectedDevices))
}
if len(contexts) == 0 {
contexts = nil