diff --git a/rpc_util_test.go b/rpc_util_test.go index 6918a004..5a802d65 100644 --- a/rpc_util_test.go +++ b/rpc_util_test.go @@ -182,6 +182,18 @@ func TestContextErr(t *testing.T) { } } +func TestErrorsWithSameParameters(t *testing.T) { + const description = "some description" + e1 := Errorf(codes.AlreadyExists, description) + e2 := Errorf(codes.AlreadyExists, description) + if e1 == e2 { + t.Fatalf("Error interfaces should not be considered equal - e1: %p - %v e2: %p - %v", e1, e1, e2, e2) + } + if Code(e1) != Code(e2) || ErrorDesc(e1) != ErrorDesc(e2) { + t.Fatalf("Expected errors to have same code and description - e1: %p - %v e2: %p - %v", e1, e1, e2, e2) + } +} + // bmEncode benchmarks encoding a Protocol Buffer message containing mSize // bytes. func bmEncode(b *testing.B, mSize int) { diff --git a/test/end2end_test.go b/test/end2end_test.go index 777c87b1..cc8bae5f 100644 --- a/test/end2end_test.go +++ b/test/end2end_test.go @@ -2129,23 +2129,5 @@ func (fw *filterWriter) Write(p []byte) (n int, err error) { } func equalErrors(l, r error) bool { - if l == nil && r != nil { - return false - } - if l != nil && r == nil { - return false - } return grpc.Code(l) == grpc.Code(r) && grpc.ErrorDesc(l) == grpc.ErrorDesc(r) } - -func TestErrorsWithSameParameters(t *testing.T) { - const description = "some description" - e1 := grpc.Errorf(codes.AlreadyExists, description) - e2 := grpc.Errorf(codes.AlreadyExists, description) - if e1 == e2 { - t.Fatalf("Error interfaces should not be considered equal - e1: %p - %v e2: %p - %v", e1, e1, e2, e2) - } - if !equalErrors(e1, e2) { - t.Fatalf("Expected errors to have same code and description - e1: %p - %v e2: %p - %v", e1, e1, e2, e2) - } -}