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

Method TestStatus_ErrorDetailsMessageV1AndV2

status/status_ext_test.go:239–262  ·  view source on GitHub ↗

TestStatus_ErrorDetailsMessageV1AndV2 verifies that status.Details() method returns the same message types when using protobuf code generated with both the MessageV1 and MessageV2 API implementations.

(t *testing.T)

Source from the content-addressed store, hash-verified

237// returns the same message types when using protobuf code generated with both the
238// MessageV1 and MessageV2 API implementations.
239func (s) TestStatus_ErrorDetailsMessageV1AndV2(t *testing.T) {
240 details := []protoadapt.MessageV1{
241 &testpb.Empty{},
242 }
243 s, err := status.New(codes.Aborted, "").WithDetails(details...)
244 if err != nil {
245 t.Fatalf("(%v).WithDetails(%+v) failed: %v", s, details, err)
246 }
247 gotDetails := s.Details()
248 for i, msg := range gotDetails {
249 if got, want := reflect.TypeOf(msg), reflect.TypeOf(details[i]); got != want {
250 t.Errorf("reflect.Typeof(%v) = %v, want = %v", msg, got, want)
251 }
252 if _, ok := msg.(protoadapt.MessageV1); !ok {
253 t.Errorf("(%v).Details() returned message that doesn't implement protoadapt.MessageV1: %v", s, msg)
254 }
255 if _, ok := msg.(protoadapt.MessageV2); !ok {
256 t.Errorf("(%v).Details() returned message that doesn't implement protoadapt.MessageV2: %v", s, msg)
257 }
258 if diff := cmp.Diff(msg, details[i], protocmp.Transform()); diff != "" {
259 t.Errorf("(%v).Details got unexpected output, diff (-got +want):\n%s", s, diff)
260 }
261 }
262}
263
264func (s) TestFromError_Wrapped(t *testing.T) {
265 base := status.New(codes.Canceled, "inner canceled")

Callers

nothing calls this directly

Calls 5

NewFunction · 0.92
WithDetailsMethod · 0.80
DetailsMethod · 0.80
FatalfMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected