diff --git a/pkg/cmd/create/create_role_test.go b/pkg/cmd/create/create_role_test.go index d3116b425..a9e1d65f5 100644 --- a/pkg/cmd/create/create_role_test.go +++ b/pkg/cmd/create/create_role_test.go @@ -20,12 +20,12 @@ import ( "reflect" "testing" + "github.com/google/go-cmp/cmp" rbac "k8s.io/api/rbac/v1" "k8s.io/apimachinery/pkg/api/equality" - "k8s.io/apimachinery/pkg/apis/meta/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/util/diff" "k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/cli-runtime/pkg/genericiooptions" "k8s.io/client-go/rest/fake" @@ -150,7 +150,7 @@ func TestCreateRole(t *testing.T) { t.Fatal(err) } if !equality.Semantic.DeepEqual(test.expectedRole, actual) { - t.Errorf("%s", diff.ObjectReflectDiff(test.expectedRole, actual)) + t.Errorf("%s", cmp.Diff(test.expectedRole, actual)) } }) } diff --git a/pkg/cmd/get/sorter_test.go b/pkg/cmd/get/sorter_test.go index f0ddace35..fd412a574 100644 --- a/pkg/cmd/get/sorter_test.go +++ b/pkg/cmd/get/sorter_test.go @@ -22,6 +22,7 @@ import ( "strings" "testing" + "github.com/google/go-cmp/cmp" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/api/resource" @@ -29,7 +30,6 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1" "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/util/diff" "k8s.io/kubectl/pkg/scheme" ) @@ -677,7 +677,7 @@ func TestSortingPrinter(t *testing.T) { t.Fatalf("%s: expected error containing: %q, got none", tt.name, tt.expectedErr) } if !reflect.DeepEqual(table, expectedTable) { - t.Errorf("[%s]\nexpected/saw:\n%s", tt.name, diff.ObjectReflectDiff(expectedTable, table)) + t.Errorf("[%s]\nexpected/saw:\n%s", tt.name, cmp.Diff(expectedTable, table)) } }) t.Run(tt.name, func(t *testing.T) { diff --git a/pkg/cmd/util/helpers_test.go b/pkg/cmd/util/helpers_test.go index 98ffe8cc7..7cf0d7083 100644 --- a/pkg/cmd/util/helpers_test.go +++ b/pkg/cmd/util/helpers_test.go @@ -36,7 +36,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/util/diff" "k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/kubectl/pkg/scheme" "k8s.io/utils/exec" @@ -155,7 +154,7 @@ func TestMerge(t *testing.T) { if err != nil { t.Errorf("testcase[%d], unexpected error: %v", i, err) } else if !apiequality.Semantic.DeepEqual(test.expected, out) { - t.Errorf("\n\ntestcase[%d]\nexpected:\n%s", i, diff.ObjectReflectDiff(test.expected, out)) + t.Errorf("\n\ntestcase[%d]\nexpected:\n%s", i, cmp.Diff(test.expected, out)) } } if test.expectErr && err == nil { @@ -238,7 +237,7 @@ func TestStrategicMerge(t *testing.T) { if err != nil { t.Errorf("testcase[%d], unexpected error: %v", i, err) } else if !apiequality.Semantic.DeepEqual(test.expected, out) { - t.Errorf("\n\ntestcase[%d]\nexpected:\n%s", i, diff.ObjectReflectDiff(test.expected, out)) + t.Errorf("\n\ntestcase[%d]\nexpected:\n%s", i, cmp.Diff(test.expected, out)) } } if test.expectErr && err == nil { @@ -300,7 +299,7 @@ func TestJSONPatch(t *testing.T) { if err != nil { t.Errorf("testcase[%d], unexpected error: %v", i, err) } else if !apiequality.Semantic.DeepEqual(test.expected, out) { - t.Errorf("\n\ntestcase[%d]\nexpected:\n%s", i, diff.ObjectReflectDiff(test.expected, out)) + t.Errorf("\n\ntestcase[%d]\nexpected:\n%s", i, cmp.Diff(test.expected, out)) } } if test.expectErr && err == nil {