mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
store: etcd: TestWatch: use cmp.Diff
Modernize the comparisons used in the watch tests to use `cmp.Diff()` for readability. Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
This commit is contained in:
parent
9f7bb4264e
commit
d17a19b39d
@ -19,11 +19,11 @@ package etcd3
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
clientv3 "go.etcd.io/etcd/client/v3"
|
clientv3 "go.etcd.io/etcd/client/v3"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/api/apitesting"
|
"k8s.io/apimachinery/pkg/api/apitesting"
|
||||||
@ -390,8 +390,8 @@ func testCheckResult(t *testing.T, expectEventType watch.EventType, w watch.Inte
|
|||||||
t.Errorf("event type want=%v, get=%v", expectEventType, res.Type)
|
t.Errorf("event type want=%v, get=%v", expectEventType, res.Type)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(expectObj, res.Object) {
|
if diff := cmp.Diff(expectObj, res.Object); diff != "" {
|
||||||
t.Errorf("obj want=\n%#v\nget=\n%#v", expectObj, res.Object)
|
t.Errorf("incorrect obj: %s", diff)
|
||||||
}
|
}
|
||||||
case <-time.After(wait.ForeverTestTimeout):
|
case <-time.After(wait.ForeverTestTimeout):
|
||||||
t.Errorf("time out after waiting %v on ResultChan", wait.ForeverTestTimeout)
|
t.Errorf("time out after waiting %v on ResultChan", wait.ForeverTestTimeout)
|
||||||
|
Loading…
Reference in New Issue
Block a user