Skip to content

Commit 424f732

Browse files
committed
Fix breaking unit tests for golang 1.24 and k8s/mount-utils 0.33.1 behaviors
1 parent 1c3f319 commit 424f732

File tree

2 files changed

+387
-194
lines changed

2 files changed

+387
-194
lines changed

pkg/gce-pd-csi-driver/controller_test.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ import (
4141
"k8s.io/client-go/util/flowcontrol"
4242
"k8s.io/klog/v2"
4343
clock "k8s.io/utils/clock/testing"
44-
"k8s.io/utils/strings/slices"
4544

4645
csi "github.com/container-storage-interface/spec/lib/go/csi"
4746
"sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/common"
@@ -5016,7 +5015,7 @@ func TestPickZonesFromTopology(t *testing.T) {
50165015
if err == nil && tc.expErr {
50175016
t.Errorf("got no error, but expected error")
50185017
}
5019-
if !slices.Equal(gotZones, tc.expZones) {
5018+
if !zonesEqual(gotZones, tc.expZones) {
50205019
t.Errorf("Expected zones: %v, but got: %v", tc.expZones, gotZones)
50215020
}
50225021
}
@@ -5026,8 +5025,12 @@ func zonesEqual(gotZones, expectedZones []string) bool {
50265025
if len(gotZones) != len(expectedZones) {
50275026
return false
50285027
}
5029-
for i := 0; i < len(gotZones); i++ {
5030-
if gotZones[i] != expectedZones[i] {
5028+
gotSet := make(map[string]bool)
5029+
for _, zone := range gotZones {
5030+
gotSet[zone] = true
5031+
}
5032+
for _, zone := range expectedZones {
5033+
if !gotSet[zone] {
50315034
return false
50325035
}
50335036
}

0 commit comments

Comments
 (0)