update vendor

Signed-off-by: Jess Frazelle <acidburn@microsoft.com>
This commit is contained in:
Jess Frazelle 2018-09-25 12:27:46 -04:00
parent 19a32db84d
commit 94d1cfbfbf
No known key found for this signature in database
GPG key ID: 18F3685C0022BFF3
10501 changed files with 2307943 additions and 29279 deletions

View file

@ -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)
}
}
}