diff --git a/pkg/controller/certificates/rootcacertpublisher/publisher_test.go b/pkg/controller/certificates/rootcacertpublisher/publisher_test.go index cb5fb132e26..67852476a42 100644 --- a/pkg/controller/certificates/rootcacertpublisher/publisher_test.go +++ b/pkg/controller/certificates/rootcacertpublisher/publisher_test.go @@ -21,10 +21,10 @@ import ( "reflect" "testing" + "github.com/google/go-cmp/cmp" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/util/diff" "k8s.io/client-go/informers" "k8s.io/client-go/kubernetes/fake" corev1listers "k8s.io/client-go/listers/core/v1" @@ -162,7 +162,7 @@ func TestConfigMapCreation(t *testing.T) { actions := client.Actions() if reflect.DeepEqual(actions, tc.ExpectActions) { - t.Errorf("Unexpected actions:\n%s", diff.ObjectGoPrintDiff(actions, tc.ExpectActions)) + t.Errorf("Unexpected actions:\n%s", cmp.Diff(actions, tc.ExpectActions)) } }) } diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/kubeopenapi_test.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/kubeopenapi_test.go index 84266bdc314..fef89bb8f5e 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/kubeopenapi_test.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/kubeopenapi_test.go @@ -22,11 +22,11 @@ import ( "testing" "time" + "github.com/google/go-cmp/cmp" fuzz "github.com/google/gofuzz" "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" - "k8s.io/apimachinery/pkg/util/diff" "k8s.io/apimachinery/pkg/util/json" ) @@ -96,7 +96,7 @@ func TestStructuralKubeOpenAPIRoundtrip(t *testing.T) { } if !reflect.DeepEqual(orig, s) { - t.Fatalf("original and result differ: %v", diff.ObjectGoPrintDiff(orig, s)) + t.Fatalf("original and result differ: %v", cmp.Diff(orig, s)) } } } diff --git a/staging/src/k8s.io/apimachinery/pkg/test/runtime_serializer_protobuf_protobuf_test.go b/staging/src/k8s.io/apimachinery/pkg/test/runtime_serializer_protobuf_protobuf_test.go index 17bcfc17a8a..75c26ca8cb7 100644 --- a/staging/src/k8s.io/apimachinery/pkg/test/runtime_serializer_protobuf_protobuf_test.go +++ b/staging/src/k8s.io/apimachinery/pkg/test/runtime_serializer_protobuf_protobuf_test.go @@ -24,15 +24,15 @@ import ( "strings" "testing" + "github.com/google/go-cmp/cmp" "github.com/stretchr/testify/require" apiequality "k8s.io/apimachinery/pkg/api/equality" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/apis/testapigroup/v1" + v1 "k8s.io/apimachinery/pkg/apis/testapigroup/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/serializer/protobuf" - "k8s.io/apimachinery/pkg/util/diff" ) type testObject struct { @@ -355,7 +355,7 @@ func TestDecodeObjects(t *testing.T) { } if !apiequality.Semantic.DeepEqual(obj, test.obj) { - t.Errorf("%d: unexpected object:\n%s", i, diff.ObjectGoPrintDiff(test.obj, obj)) + t.Errorf("%d: unexpected object:\n%s", i, cmp.Diff(test.obj, obj)) continue } } diff --git a/staging/src/k8s.io/apiserver/pkg/authentication/authenticator/audagnostic_test.go b/staging/src/k8s.io/apiserver/pkg/authentication/authenticator/audagnostic_test.go index 0152b9a6e38..bc8c0cfa833 100644 --- a/staging/src/k8s.io/apiserver/pkg/authentication/authenticator/audagnostic_test.go +++ b/staging/src/k8s.io/apiserver/pkg/authentication/authenticator/audagnostic_test.go @@ -23,7 +23,7 @@ import ( "reflect" "testing" - "k8s.io/apimachinery/pkg/util/diff" + "github.com/google/go-cmp/cmp" "k8s.io/apiserver/pkg/authentication/user" ) @@ -219,7 +219,7 @@ func TestAuthenticate(t *testing.T) { t.Errorf("Unexpected authentication. got=%v, want=%v", got, want) } if got, want := resp, treq.wantResp; !reflect.DeepEqual(got, want) { - t.Errorf("Unexpected response. diff:\n%v", diff.ObjectGoPrintDiff(got, want)) + t.Errorf("Unexpected response. diff:\n%v", cmp.Diff(got, want)) } }) } diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/rest_test.go b/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/rest_test.go index 5c13c26b667..1d327bad737 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/rest_test.go +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/rest_test.go @@ -28,6 +28,7 @@ import ( "time" jsonpatch "github.com/evanphx/json-patch" + "github.com/google/go-cmp/cmp" fuzz "github.com/google/gofuzz" apiequality "k8s.io/apimachinery/pkg/api/equality" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -583,7 +584,7 @@ func (tc *patchTestCase) Run(t *testing.T) { reallyExpectedPod := expectedObj.(*example.Pod) if !reflect.DeepEqual(*reallyExpectedPod, *resultPod) { - t.Errorf("%s mismatch: %v\n", tc.name, diff.ObjectGoPrintDiff(reallyExpectedPod, resultPod)) + t.Errorf("%s mismatch: %v\n", tc.name, cmp.Diff(reallyExpectedPod, resultPod)) continue } } diff --git a/staging/src/k8s.io/apiserver/plugin/pkg/authorizer/webhook/webhook_v1_test.go b/staging/src/k8s.io/apiserver/plugin/pkg/authorizer/webhook/webhook_v1_test.go index 07b3d4148f0..6d21e40a2a1 100644 --- a/staging/src/k8s.io/apiserver/plugin/pkg/authorizer/webhook/webhook_v1_test.go +++ b/staging/src/k8s.io/apiserver/plugin/pkg/authorizer/webhook/webhook_v1_test.go @@ -34,9 +34,9 @@ import ( "text/template" "time" + "github.com/google/go-cmp/cmp" authorizationv1 "k8s.io/api/authorization/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/diff" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/apiserver/pkg/authentication/user" "k8s.io/apiserver/pkg/authorization/authorizer" @@ -556,7 +556,7 @@ func TestV1Webhook(t *testing.T) { continue } if !reflect.DeepEqual(gotAttr, tt.want) { - t.Errorf("case %d: got != want:\n%s", i, diff.ObjectGoPrintDiff(gotAttr, tt.want)) + t.Errorf("case %d: got != want:\n%s", i, cmp.Diff(gotAttr, tt.want)) } } } diff --git a/staging/src/k8s.io/apiserver/plugin/pkg/authorizer/webhook/webhook_v1beta1_test.go b/staging/src/k8s.io/apiserver/plugin/pkg/authorizer/webhook/webhook_v1beta1_test.go index d3ba93db435..8023a57afe9 100644 --- a/staging/src/k8s.io/apiserver/plugin/pkg/authorizer/webhook/webhook_v1beta1_test.go +++ b/staging/src/k8s.io/apiserver/plugin/pkg/authorizer/webhook/webhook_v1beta1_test.go @@ -34,9 +34,9 @@ import ( "text/template" "time" + "github.com/google/go-cmp/cmp" authorizationv1beta1 "k8s.io/api/authorization/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/diff" "k8s.io/apiserver/pkg/authentication/user" "k8s.io/apiserver/pkg/authorization/authorizer" webhookutil "k8s.io/apiserver/pkg/util/webhook" @@ -548,7 +548,7 @@ func TestV1beta1Webhook(t *testing.T) { continue } if !reflect.DeepEqual(gotAttr, tt.want) { - t.Errorf("case %d: got != want:\n%s", i, diff.ObjectGoPrintDiff(gotAttr, tt.want)) + t.Errorf("case %d: got != want:\n%s", i, cmp.Diff(gotAttr, tt.want)) } } } diff --git a/staging/src/k8s.io/client-go/dynamic/fake/simple_test.go b/staging/src/k8s.io/client-go/dynamic/fake/simple_test.go index e74b6ff0414..7e487616355 100644 --- a/staging/src/k8s.io/client-go/dynamic/fake/simple_test.go +++ b/staging/src/k8s.io/client-go/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/staging/src/k8s.io/client-go/metadata/fake/simple_test.go b/staging/src/k8s.io/client-go/metadata/fake/simple_test.go index 219be4e7ea4..a8369f9f1fb 100644 --- a/staging/src/k8s.io/client-go/metadata/fake/simple_test.go +++ b/staging/src/k8s.io/client-go/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/staging/src/k8s.io/client-go/tools/record/events_cache_test.go b/staging/src/k8s.io/client-go/tools/record/events_cache_test.go index 2ede35508c9..7c9c931604c 100644 --- a/staging/src/k8s.io/client-go/tools/record/events_cache_test.go +++ b/staging/src/k8s.io/client-go/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 diff --git a/test/integration/etcd/etcd_storage_path_test.go b/test/integration/etcd/etcd_storage_path_test.go index c5ecbe42816..53c24eb37c6 100644 --- a/test/integration/etcd/etcd_storage_path_test.go +++ b/test/integration/etcd/etcd_storage_path_test.go @@ -25,6 +25,7 @@ import ( "strings" "testing" + "github.com/google/go-cmp/cmp" clientv3 "go.etcd.io/etcd/client/v3" v1 "k8s.io/api/core/v1" @@ -33,7 +34,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/util/diff" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/apiserver/pkg/util/feature" "k8s.io/client-go/dynamic" @@ -203,7 +203,7 @@ func TestEtcdStoragePath(t *testing.T) { } if !apiequality.Semantic.DeepDerivative(input, output) { - t.Errorf("Test stub for %s does not match: %s", kind, diff.ObjectGoPrintDiff(input, output)) + t.Errorf("Test stub for %s does not match: %s", kind, cmp.Diff(input, output)) } addGVKToEtcdBucket(cohabitatingResources, actualGVK, getEtcdBucket(testData.ExpectedEtcdPath))