mirror of
https://github.com/kubernetes/client-go.git
synced 2025-06-29 00:17:46 +00:00
Replace uses of ObjectReflectDiff with cmp.Diff
ObjectReflectDiff is already a shim over cmp.Diff, so no actual output or behavior changes Kubernetes-commit: bc302fa4144d21a338683cd83701661f97be4aba
This commit is contained in:
parent
c4339eeca9
commit
12553015e2
@ -36,7 +36,6 @@ import (
|
|||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
"k8s.io/apimachinery/pkg/version"
|
"k8s.io/apimachinery/pkg/version"
|
||||||
"k8s.io/client-go/openapi"
|
"k8s.io/client-go/openapi"
|
||||||
@ -437,7 +436,7 @@ func TestGetServerResourcesForGroupVersion(t *testing.T) {
|
|||||||
"extensions/v1beta10",
|
"extensions/v1beta10",
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(expectedGroupVersions, serverGroupVersions) {
|
if !reflect.DeepEqual(expectedGroupVersions, serverGroupVersions) {
|
||||||
t.Errorf("unexpected group versions: %v", diff.ObjectReflectDiff(expectedGroupVersions, serverGroupVersions))
|
t.Errorf("unexpected group versions: %v", cmp.Diff(expectedGroupVersions, serverGroupVersions))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,11 +26,11 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
"k8s.io/client-go/rest"
|
"k8s.io/client-go/rest"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ func TestClient(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(expect, obj) {
|
if !reflect.DeepEqual(expect, obj) {
|
||||||
t.Fatal(diff.ObjectReflectDiff(expect, obj))
|
t.Fatal(cmp.Diff(expect, obj))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -146,7 +146,7 @@ func TestClient(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(expect, objs.Items) {
|
if !reflect.DeepEqual(expect, objs.Items) {
|
||||||
t.Fatal(diff.ObjectReflectDiff(expect, objs.Items))
|
t.Fatal(cmp.Diff(expect, objs.Items))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -45,7 +45,6 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/apimachinery/pkg/runtime/serializer"
|
"k8s.io/apimachinery/pkg/runtime/serializer"
|
||||||
"k8s.io/apimachinery/pkg/runtime/serializer/streaming"
|
"k8s.io/apimachinery/pkg/runtime/serializer/streaming"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
utilnet "k8s.io/apimachinery/pkg/util/net"
|
utilnet "k8s.io/apimachinery/pkg/util/net"
|
||||||
"k8s.io/apimachinery/pkg/watch"
|
"k8s.io/apimachinery/pkg/watch"
|
||||||
@ -925,22 +924,22 @@ func TestTransformUnstructuredError(t *testing.T) {
|
|||||||
expect = err
|
expect = err
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(expect, transformed) {
|
if !reflect.DeepEqual(expect, transformed) {
|
||||||
t.Errorf("unexpected Error(): %s", diff.ObjectReflectDiff(expect, transformed))
|
t.Errorf("unexpected Error(): %s", cmp.Diff(expect, transformed))
|
||||||
}
|
}
|
||||||
|
|
||||||
// verify result.Get properly transforms the error
|
// verify result.Get properly transforms the error
|
||||||
if _, err := result.Get(); !reflect.DeepEqual(expect, err) {
|
if _, err := result.Get(); !reflect.DeepEqual(expect, err) {
|
||||||
t.Errorf("unexpected error on Get(): %s", diff.ObjectReflectDiff(expect, err))
|
t.Errorf("unexpected error on Get(): %s", cmp.Diff(expect, err))
|
||||||
}
|
}
|
||||||
|
|
||||||
// verify result.Into properly handles the error
|
// verify result.Into properly handles the error
|
||||||
if err := result.Into(&v1.Pod{}); !reflect.DeepEqual(expect, err) {
|
if err := result.Into(&v1.Pod{}); !reflect.DeepEqual(expect, err) {
|
||||||
t.Errorf("unexpected error on Into(): %s", diff.ObjectReflectDiff(expect, err))
|
t.Errorf("unexpected error on Into(): %s", cmp.Diff(expect, err))
|
||||||
}
|
}
|
||||||
|
|
||||||
// verify result.Raw leaves the error in the untransformed state
|
// verify result.Raw leaves the error in the untransformed state
|
||||||
if _, err := result.Raw(); !reflect.DeepEqual(result.err, err) {
|
if _, err := result.Raw(); !reflect.DeepEqual(result.err, err) {
|
||||||
t.Errorf("unexpected error on Raw(): %s", diff.ObjectReflectDiff(expect, err))
|
t.Errorf("unexpected error on Raw(): %s", cmp.Diff(expect, err))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -1220,7 +1219,7 @@ func TestRequestWatch(t *testing.T) {
|
|||||||
t.Fatalf("Watch closed early, %d/%d read", i, len(testCase.Expect))
|
t.Fatalf("Watch closed early, %d/%d read", i, len(testCase.Expect))
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(evt, out) {
|
if !reflect.DeepEqual(evt, out) {
|
||||||
t.Fatalf("Event %d does not match: %s", i, diff.ObjectReflectDiff(evt, out))
|
t.Fatalf("Event %d does not match: %s", i, cmp.Diff(evt, out))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,10 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
"sigs.k8s.io/yaml"
|
"sigs.k8s.io/yaml"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
|
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
|
||||||
clientcmdlatest "k8s.io/client-go/tools/clientcmd/api/latest"
|
clientcmdlatest "k8s.io/client-go/tools/clientcmd/api/latest"
|
||||||
)
|
)
|
||||||
@ -248,7 +248,7 @@ preferences: {}
|
|||||||
users: null
|
users: null
|
||||||
`)
|
`)
|
||||||
if !bytes.Equal(expected, data) {
|
if !bytes.Equal(expected, data) {
|
||||||
t.Error(diff.ObjectReflectDiff(string(expected), string(data)))
|
t.Error(cmp.Diff(string(expected), string(data)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,9 +21,9 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
eventsv1 "k8s.io/api/events/v1"
|
eventsv1 "k8s.io/api/events/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
"k8s.io/client-go/kubernetes/fake"
|
"k8s.io/client-go/kubernetes/fake"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ func TestRecordEventToSink(t *testing.T) {
|
|||||||
|
|
||||||
recordedEvent := recordedEvents.Items[0]
|
recordedEvent := recordedEvents.Items[0]
|
||||||
if !reflect.DeepEqual(recordedEvent, tc.expectedRecordedEvent) {
|
if !reflect.DeepEqual(recordedEvent, tc.expectedRecordedEvent) {
|
||||||
t.Errorf("expected to have recorded Event: %#+v, got: %#+v\n diff: %s", tc.expectedRecordedEvent, recordedEvent, diff.ObjectReflectDiff(tc.expectedRecordedEvent, recordedEvent))
|
t.Errorf("expected to have recorded Event: %#+v, got: %#+v\n diff: %s", tc.expectedRecordedEvent, recordedEvent, cmp.Diff(tc.expectedRecordedEvent, recordedEvent))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -24,13 +24,13 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
coordinationv1 "k8s.io/api/coordination/v1"
|
coordinationv1 "k8s.io/api/coordination/v1"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/equality"
|
"k8s.io/apimachinery/pkg/api/equality"
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
"k8s.io/client-go/kubernetes/fake"
|
"k8s.io/client-go/kubernetes/fake"
|
||||||
fakeclient "k8s.io/client-go/testing"
|
fakeclient "k8s.io/client-go/testing"
|
||||||
@ -371,13 +371,13 @@ func TestLeaseSpecToLeaderElectionRecordRoundTrip(t *testing.T) {
|
|||||||
newSpec := rl.LeaderElectionRecordToLeaseSpec(oldRecord)
|
newSpec := rl.LeaderElectionRecordToLeaseSpec(oldRecord)
|
||||||
|
|
||||||
if !equality.Semantic.DeepEqual(oldSpec, newSpec) {
|
if !equality.Semantic.DeepEqual(oldSpec, newSpec) {
|
||||||
t.Errorf("diff: %v", diff.ObjectReflectDiff(oldSpec, newSpec))
|
t.Errorf("diff: %v", cmp.Diff(oldSpec, newSpec))
|
||||||
}
|
}
|
||||||
|
|
||||||
newRecord := rl.LeaseSpecToLeaderElectionRecord(&newSpec)
|
newRecord := rl.LeaseSpecToLeaderElectionRecord(&newSpec)
|
||||||
|
|
||||||
if !equality.Semantic.DeepEqual(oldRecord, newRecord) {
|
if !equality.Semantic.DeepEqual(oldRecord, newRecord) {
|
||||||
t.Errorf("diff: %v", diff.ObjectReflectDiff(oldRecord, newRecord))
|
t.Errorf("diff: %v", cmp.Diff(oldRecord, newRecord))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,13 +25,13 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
|
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
"k8s.io/apimachinery/pkg/watch"
|
"k8s.io/apimachinery/pkg/watch"
|
||||||
fakeclientset "k8s.io/client-go/kubernetes/fake"
|
fakeclientset "k8s.io/client-go/kubernetes/fake"
|
||||||
testcore "k8s.io/client-go/testing"
|
testcore "k8s.io/client-go/testing"
|
||||||
@ -260,7 +260,7 @@ func TestNewInformerWatcher(t *testing.T) {
|
|||||||
sort.Sort(byEventTypeAndName(result))
|
sort.Sort(byEventTypeAndName(result))
|
||||||
|
|
||||||
if !reflect.DeepEqual(expected, result) {
|
if !reflect.DeepEqual(expected, result) {
|
||||||
t.Error(spew.Errorf("\nexpected: %#v,\ngot: %#v,\ndiff: %s", expected, result, diff.ObjectReflectDiff(expected, result)))
|
t.Error(spew.Errorf("\nexpected: %#v,\ngot: %#v,\ndiff: %s", expected, result, cmp.Diff(expected, result)))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,12 +27,12 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
|
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
"k8s.io/apimachinery/pkg/watch"
|
"k8s.io/apimachinery/pkg/watch"
|
||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
@ -564,7 +564,7 @@ func TestRetryWatcher(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !reflect.DeepEqual(tc.expected, got) {
|
if !reflect.DeepEqual(tc.expected, got) {
|
||||||
t.Fatal(spew.Errorf("expected %#+v, got %#+v;\ndiff: %s", tc.expected, got, diff.ObjectReflectDiff(tc.expected, got)))
|
t.Fatal(spew.Errorf("expected %#+v, got %#+v;\ndiff: %s", tc.expected, got, cmp.Diff(tc.expected, got)))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user