update vendor
Signed-off-by: Jess Frazelle <acidburn@microsoft.com>
This commit is contained in:
parent
19a32db84d
commit
94d1cfbfbf
10501 changed files with 2307943 additions and 29279 deletions
60
vendor/google.golang.org/grpc/status/status_test.go
generated
vendored
60
vendor/google.golang.org/grpc/status/status_test.go
generated
vendored
|
@ -28,6 +28,7 @@ import (
|
|||
"github.com/golang/protobuf/ptypes"
|
||||
apb "github.com/golang/protobuf/ptypes/any"
|
||||
dpb "github.com/golang/protobuf/ptypes/duration"
|
||||
"golang.org/x/net/context"
|
||||
cpb "google.golang.org/genproto/googleapis/rpc/code"
|
||||
epb "google.golang.org/genproto/googleapis/rpc/errdetails"
|
||||
spb "google.golang.org/genproto/googleapis/rpc/status"
|
||||
|
@ -119,6 +120,47 @@ func TestFromErrorOK(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
type customError struct {
|
||||
Code codes.Code
|
||||
Message string
|
||||
Details []*apb.Any
|
||||
}
|
||||
|
||||
func (c customError) Error() string {
|
||||
return fmt.Sprintf("rpc error: code = %s desc = %s", c.Code, c.Message)
|
||||
}
|
||||
|
||||
func (c customError) GRPCStatus() *Status {
|
||||
return &Status{
|
||||
s: &spb.Status{
|
||||
Code: int32(c.Code),
|
||||
Message: c.Message,
|
||||
Details: c.Details,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func TestFromErrorImplementsInterface(t *testing.T) {
|
||||
code, message := codes.Internal, "test description"
|
||||
details := []*apb.Any{{
|
||||
TypeUrl: "testUrl",
|
||||
Value: []byte("testValue"),
|
||||
}}
|
||||
err := customError{
|
||||
Code: code,
|
||||
Message: message,
|
||||
Details: details,
|
||||
}
|
||||
s, ok := FromError(err)
|
||||
if !ok || s.Code() != code || s.Message() != message || s.Err() == nil {
|
||||
t.Fatalf("FromError(%v) = %v, %v; want <Code()=%s, Message()=%q, Err()!=nil>, true", err, s, ok, code, message)
|
||||
}
|
||||
pd := s.Proto().GetDetails()
|
||||
if len(pd) != 1 || !reflect.DeepEqual(pd[0], details[0]) {
|
||||
t.Fatalf("s.Proto.GetDetails() = %v; want <Details()=%s>", pd, details)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFromErrorUnknownError(t *testing.T) {
|
||||
code, message := codes.Unknown, "unknown error"
|
||||
err := errors.New("unknown error")
|
||||
|
@ -286,3 +328,21 @@ func mustMarshalAny(msg proto.Message) *apb.Any {
|
|||
}
|
||||
return any
|
||||
}
|
||||
|
||||
func TestFromContextError(t *testing.T) {
|
||||
testCases := []struct {
|
||||
in error
|
||||
want *Status
|
||||
}{
|
||||
{in: nil, want: New(codes.OK, "")},
|
||||
{in: context.DeadlineExceeded, want: New(codes.DeadlineExceeded, context.DeadlineExceeded.Error())},
|
||||
{in: context.Canceled, want: New(codes.Canceled, context.Canceled.Error())},
|
||||
{in: errors.New("other"), want: New(codes.Unknown, "other")},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
got := FromContextError(tc.in)
|
||||
if got.Code() != tc.want.Code() || got.Message() != tc.want.Message() {
|
||||
t.Errorf("FromContextError(%v) = %v; want %v", tc.in, got, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue