fix the flaky test in crd package

This commit is contained in:
Jingfang Liu
2018-10-08 16:06:35 -07:00
parent 30814302af
commit 62f7cdbb43

View File

@@ -18,6 +18,7 @@ package crds
import (
"reflect"
"sort"
"testing"
"sigs.k8s.io/kustomize/pkg/gvk"
@@ -181,6 +182,14 @@ func TestRegisterCRD(t *testing.T) {
pathconfig, _ := registerCRD(ldr, "/testpath/crd.json")
sort.Slice(expected.NameReference[:], func(i, j int) bool {
return expected.NameReference[i].Gvk.String() < expected.NameReference[j].Gvk.String()
})
sort.Slice(pathconfig.NameReference[:], func(i, j int) bool {
return pathconfig.NameReference[i].Gvk.String() < pathconfig.NameReference[j].Gvk.String()
})
if !reflect.DeepEqual(pathconfig, expected) {
t.Fatalf("expected\n %v\n but got\n %v\n", expected, pathconfig)
}