diff --git a/dynamic/fake/simple_test.go b/dynamic/fake/simple_test.go index e74b6ff0..7e487616 100644 --- a/dynamic/fake/simple_test.go +++ b/dynamic/fake/simple_test.go @@ -28,7 +28,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/util/diff" ) const ( @@ -80,7 +79,7 @@ func TestGet(t *testing.T) { }, } if !equality.Semantic.DeepEqual(get, expected) { - t.Fatal(diff.ObjectGoPrintDiff(expected, get)) + t.Fatal(cmp.Diff(expected, get)) } } @@ -99,7 +98,7 @@ func TestListDecoding(t *testing.T) { Items: []unstructured.Unstructured{}, } if !equality.Semantic.DeepEqual(list, expectedList) { - t.Fatal(diff.ObjectGoPrintDiff(expectedList, list)) + t.Fatal(cmp.Diff(expectedList, list)) } } @@ -117,7 +116,7 @@ func TestGetDecoding(t *testing.T) { }, } if !equality.Semantic.DeepEqual(get, expectedObj) { - t.Fatal(diff.ObjectGoPrintDiff(expectedObj, get)) + t.Fatal(cmp.Diff(expectedObj, get)) } } @@ -145,7 +144,7 @@ func TestList(t *testing.T) { *newUnstructured("group/version", "TheKind", "ns-foo", "name-foo"), } if !equality.Semantic.DeepEqual(listFirst.Items, expected) { - t.Fatal(diff.ObjectGoPrintDiff(expected, listFirst.Items)) + t.Fatal(cmp.Diff(expected, listFirst.Items)) } } @@ -189,7 +188,7 @@ func Test_ListKind(t *testing.T) { }, } if !equality.Semantic.DeepEqual(listFirst, expectedList) { - t.Fatal(diff.ObjectGoPrintDiff(expectedList, listFirst)) + t.Fatal(cmp.Diff(expectedList, listFirst)) } } @@ -242,7 +241,7 @@ func (tc *patchTestCase) verifyResult(result *unstructured.Unstructured) error { return nil } if !equality.Semantic.DeepEqual(result, tc.expectedPatchedObject) { - return fmt.Errorf("unexpected diff in received object: %s", diff.ObjectGoPrintDiff(tc.expectedPatchedObject, result)) + return fmt.Errorf("unexpected diff in received object: %s", cmp.Diff(tc.expectedPatchedObject, result)) } return nil } diff --git a/metadata/fake/simple_test.go b/metadata/fake/simple_test.go index 219be4e7..a8369f9f 100644 --- a/metadata/fake/simple_test.go +++ b/metadata/fake/simple_test.go @@ -21,12 +21,12 @@ import ( "fmt" "testing" + "github.com/google/go-cmp/cmp" "k8s.io/apimachinery/pkg/api/equality" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/util/diff" ) const ( @@ -79,7 +79,7 @@ func TestList(t *testing.T) { *newPartialObjectMetadata("group/version", "TheKind", "ns-foo", "name-foo"), } if !equality.Semantic.DeepEqual(listFirst.Items, expected) { - t.Fatal(diff.ObjectGoPrintDiff(expected, listFirst.Items)) + t.Fatal(cmp.Diff(expected, listFirst.Items)) } } @@ -134,7 +134,7 @@ func (tc *patchTestCase) verifyResult(result *metav1.PartialObjectMetadata) erro return nil } if !equality.Semantic.DeepEqual(result, tc.expectedPatchedObject) { - return fmt.Errorf("unexpected diff in received object: %s", diff.ObjectGoPrintDiff(tc.expectedPatchedObject, result)) + return fmt.Errorf("unexpected diff in received object: %s", cmp.Diff(tc.expectedPatchedObject, result)) } return nil } diff --git a/tools/record/events_cache_test.go b/tools/record/events_cache_test.go index 2ede3550..7c9c9316 100644 --- a/tools/record/events_cache_test.go +++ b/tools/record/events_cache_test.go @@ -23,9 +23,9 @@ import ( "testing" "time" + "github.com/google/go-cmp/cmp" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/diff" testclocks "k8s.io/utils/clock/testing" ) @@ -121,7 +121,7 @@ func validateEvent(messagePrefix string, actualEvent *v1.Event, expectedEvent *v } recvEvent.Name = expectedEvent.Name if e, a := expectedEvent, &recvEvent; !reflect.DeepEqual(e, a) { - t.Errorf("%v - diff: %s", messagePrefix, diff.ObjectGoPrintDiff(e, a)) + t.Errorf("%v - diff: %s", messagePrefix, cmp.Diff(e, a)) } recvEvent.FirstTimestamp = actualFirstTimestamp recvEvent.LastTimestamp = actualLastTimestamp