| 324 | } |
| 325 | |
| 326 | func (s) TestToRPCErr(t *testing.T) { |
| 327 | for _, test := range []struct { |
| 328 | // input |
| 329 | errIn error |
| 330 | // outputs |
| 331 | errOut error |
| 332 | }{ |
| 333 | {transport.ErrConnClosing, status.Error(codes.Unavailable, transport.ErrConnClosing.Desc)}, |
| 334 | {io.ErrUnexpectedEOF, status.Error(codes.Internal, io.ErrUnexpectedEOF.Error())}, |
| 335 | } { |
| 336 | err := toRPCErr(test.errIn) |
| 337 | if _, ok := status.FromError(err); !ok { |
| 338 | t.Errorf("toRPCErr{%v} returned type %T, want %T", test.errIn, err, status.Error) |
| 339 | } |
| 340 | if !testutils.StatusErrEqual(err, test.errOut) { |
| 341 | t.Errorf("toRPCErr{%v} = %v \nwant %v", test.errIn, err, test.errOut) |
| 342 | } |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | // bmEncode benchmarks encoding a Protocol Buffer message containing mSize |
| 347 | // bytes. |