mirror of https://github.com/grpc/grpc-go.git
test: loosen metadata error check to reduce dependence on exact library errors (#5650)
This commit is contained in:
parent
552de12024
commit
21f0259e42
|
|
@ -23,6 +23,7 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
|
@ -45,12 +46,12 @@ func (s) TestInvalidMetadata(t *testing.T) {
|
|||
{
|
||||
md: map[string][]string{string(rune(0x19)): {"testVal"}},
|
||||
want: status.Error(codes.Internal, "header key \"\\x19\" contains illegal characters not in [0-9a-z-_.]"),
|
||||
recv: status.Error(codes.Internal, "invalid header field name \"\\x19\""),
|
||||
recv: status.Error(codes.Internal, "invalid header field"),
|
||||
},
|
||||
{
|
||||
md: map[string][]string{"test": {string(rune(0x19))}},
|
||||
want: status.Error(codes.Internal, "header key \"test\" contains value with non-printable ASCII characters"),
|
||||
recv: status.Error(codes.Internal, "invalid header field value \"\\x19\""),
|
||||
recv: status.Error(codes.Internal, "invalid header field"),
|
||||
},
|
||||
{
|
||||
md: map[string][]string{"test-bin": {string(rune(0x19))}},
|
||||
|
|
@ -113,7 +114,7 @@ func (s) TestInvalidMetadata(t *testing.T) {
|
|||
if err := stream.Send(&testpb.StreamingOutputCallRequest{}); err != nil {
|
||||
t.Errorf("call ss.Client stream Send(nil) will success but got err :%v", err)
|
||||
}
|
||||
if _, err := stream.Recv(); !reflect.DeepEqual(test.recv, err) {
|
||||
if _, err := stream.Recv(); status.Code(err) != status.Code(test.recv) || !strings.Contains(err.Error(), test.recv.Error()) {
|
||||
t.Errorf("stream.Recv() = _, get err :%v, want err :%v", err, test.recv)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue