MCPcopy
hub / github.com/grpc/grpc-go / TestFromErrorImplementsInterface

Method TestFromErrorImplementsInterface

status/status_test.go:167–186  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

165}
166
167func (s) TestFromErrorImplementsInterface(t *testing.T) {
168 code, message := codes.Internal, "test description"
169 details := []*anypb.Any{{
170 TypeUrl: "testUrl",
171 Value: []byte("testValue"),
172 }}
173 err := customError{
174 Code: code,
175 Message: message,
176 Details: details,
177 }
178 s, ok := FromError(err)
179 if !ok || s.Code() != code || s.Message() != message || s.Err() == nil {
180 t.Fatalf("FromError(%v) = %v, %v; want <Code()=%s, Message()=%q, Err()!=nil>, true", err, s, ok, code, message)
181 }
182 pd := s.Proto().GetDetails()
183 if len(pd) != 1 || !proto.Equal(pd[0], details[0]) {
184 t.Fatalf("s.Proto.GetDetails() = %v; want <Details()=%s>", pd, details)
185 }
186}
187
188func (s) TestFromErrorUnknownError(t *testing.T) {
189 code, message := codes.Unknown, "unknown error"

Callers

nothing calls this directly

Calls 8

FromErrorFunction · 0.85
CodeMethod · 0.80
MessageMethod · 0.80
ErrMethod · 0.80
GetDetailsMethod · 0.80
ProtoMethod · 0.80
FatalfMethod · 0.65
EqualMethod · 0.65

Tested by

no test coverage detected