Use cmp.Diff instead of diff.Object* in pkg/api

This commit is contained in:
Jie Shen
2021-03-17 17:35:21 +08:00
committed by drfish
parent 2a26f276a8
commit 3807a92df0
10 changed files with 61 additions and 55 deletions

View File

@@ -22,6 +22,7 @@ import (
"sort"
"testing"
"github.com/google/go-cmp/cmp"
fuzz "github.com/google/gofuzz"
jsoniter "github.com/json-iterator/go"
@@ -33,7 +34,6 @@ import (
metaunstruct "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/json"
"k8s.io/kubernetes/pkg/api/legacyscheme"
api "k8s.io/kubernetes/pkg/apis/core"
@@ -96,7 +96,7 @@ func doRoundTrip(t *testing.T, internalVersion schema.GroupVersion, externalVers
return
}
if !apiequality.Semantic.DeepEqual(item, unmarshalledObj) {
t.Errorf("Object changed during JSON operations, diff: %v", diff.ObjectReflectDiff(item, unmarshalledObj))
t.Errorf("Object changed during JSON operations, diff: %v", cmp.Diff(item, unmarshalledObj))
return
}
@@ -114,7 +114,7 @@ func doRoundTrip(t *testing.T, internalVersion schema.GroupVersion, externalVers
}
if !apiequality.Semantic.DeepEqual(item, newObj) {
t.Errorf("Object changed, diff: %v", diff.ObjectReflectDiff(item, newObj))
t.Errorf("Object changed, diff: %v", cmp.Diff(item, newObj))
}
}