Skip to content

Commit 62f7cdb

Browse files
committed
fix the flaky test in crd package
1 parent 3081430 commit 62f7cdb

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pkg/crds/crds_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package crds
1818

1919
import (
2020
"reflect"
21+
"sort"
2122
"testing"
2223

2324
"sigs.k8s.io/kustomize/pkg/gvk"
@@ -181,6 +182,14 @@ func TestRegisterCRD(t *testing.T) {
181182

182183
pathconfig, _ := registerCRD(ldr, "/testpath/crd.json")
183184

185+
sort.Slice(expected.NameReference[:], func(i, j int) bool {
186+
return expected.NameReference[i].Gvk.String() < expected.NameReference[j].Gvk.String()
187+
})
188+
189+
sort.Slice(pathconfig.NameReference[:], func(i, j int) bool {
190+
return pathconfig.NameReference[i].Gvk.String() < pathconfig.NameReference[j].Gvk.String()
191+
})
192+
184193
if !reflect.DeepEqual(pathconfig, expected) {
185194
t.Fatalf("expected\n %v\n but got\n %v\n", expected, pathconfig)
186195
}

0 commit comments

Comments
 (0)