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)
| 237 | // returns the same message types when using protobuf code generated with both the |
| 238 | // MessageV1 and MessageV2 API implementations. |
| 239 | func (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 | |
| 264 | func (s) TestFromError_Wrapped(t *testing.T) { |
| 265 | base := status.New(codes.Canceled, "inner canceled") |
nothing calls this directly
no test coverage detected