Skip to content

Commit dd140d2

Browse files
author
Ryan Zhang
committed
fix UT
Signed-off-by: Ryan Zhang <[email protected]>
1 parent a11e702 commit dd140d2

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

pkg/utils/controller/controller_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import (
2020
"context"
2121
"errors"
2222
"fmt"
23+
"maps"
24+
"slices"
2325
"testing"
2426

2527
"github.com/google/go-cmp/cmp"
@@ -492,8 +494,13 @@ func TestFetchAllClusterResourceSnapshots(t *testing.T) {
492494
return s1 < s2
493495
}),
494496
}
495-
if diff := cmp.Diff(tc.want, got, options...); diff != "" {
496-
t.Errorf("FetchAllClusterResourceSnapshots() mismatch (-want, +got):\n%s", diff)
497+
theSortedKeys := slices.Sorted(maps.Keys(got))
498+
for i := range theSortedKeys {
499+
key := theSortedKeys[i]
500+
wantResourceSnapshotObj := tc.want[key]
501+
if diff := cmp.Diff(wantResourceSnapshotObj, got[key], options...); diff != "" {
502+
t.Errorf("FetchAllClusterResourceSnapshots() mismatch (-want, +got):\n%s", diff)
503+
}
497504
}
498505
})
499506
}

0 commit comments

Comments
 (0)