Skip to content

Commit a7fee9f

Browse files
authored
Use proto.Equal for equalities on Go proto messages (#1204)
1 parent c73e016 commit a7fee9f

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

reflection/serverreflection_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func TestFileDescForType(t *testing.T) {
9494
{reflect.TypeOf(pb.ToBeExtended{}), fdProto2},
9595
} {
9696
fd, err := s.fileDescForType(test.st)
97-
if err != nil || !reflect.DeepEqual(fd, test.wantFd) {
97+
if err != nil || !proto.Equal(fd, test.wantFd) {
9898
t.Errorf("fileDescForType(%q) = %q, %v, want %q, <nil>", test.st, fd, err, test.wantFd)
9999
}
100100
}
@@ -138,7 +138,7 @@ func TestFileDescContainingExtension(t *testing.T) {
138138
{reflect.TypeOf(pb.ToBeExtended{}), 29, fdProto2Ext2},
139139
} {
140140
fd, err := s.fileDescContainingExtension(test.st, test.extNum)
141-
if err != nil || !reflect.DeepEqual(fd, test.want) {
141+
if err != nil || !proto.Equal(fd, test.want) {
142142
t.Errorf("fileDescContainingExtension(%q) = %q, %v, want %q, <nil>", test.st, fd, err, test.want)
143143
}
144144
}

status/status_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import (
3737
"reflect"
3838
"testing"
3939

40+
"github.com/golang/protobuf/proto"
4041
apb "github.com/golang/protobuf/ptypes/any"
4142
spb "google.golang.org/genproto/googleapis/rpc/status"
4243
"google.golang.org/grpc/codes"
@@ -59,7 +60,7 @@ func TestFromToProto(t *testing.T) {
5960
}
6061

6162
err := FromProto(s)
62-
if got := err.Proto(); !reflect.DeepEqual(s, got) {
63+
if got := err.Proto(); !proto.Equal(s, got) {
6364
t.Fatalf("Expected errors to be identical - s: %v got: %v", s, got)
6465
}
6566
}

0 commit comments

Comments
 (0)