Replace uses of ObjectGoPrintDiff with cmp.Diff

ObjectGoPrintDiff is already a shim over cmp.Diff, so no actual output
or behavior changes

Kubernetes-commit: 9627c50ef37f3b5274486e6f5ad37b73b1b69bf0
This commit is contained in:
Tim Hockin 2023-03-23 11:31:25 -07:00 committed by Kubernetes Publisher
parent 1431da0154
commit aa9b8ec0fe
4 changed files with 8 additions and 7 deletions

View File

@ -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))
}
})
}

View File

@ -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
}
}

View File

@ -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))
}
}
}

View File

@ -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))
}
}
}