decodeErrorEnvelope unmarshals a typed error envelope and returns its top-level "error" object, failing the test if the shape is unexpected.
(t *testing.T, raw []byte)
| 369 | // decodeErrorEnvelope unmarshals a typed error envelope and returns its |
| 370 | // top-level "error" object, failing the test if the shape is unexpected. |
| 371 | func decodeErrorEnvelope(t *testing.T, raw []byte) map[string]any { |
| 372 | t.Helper() |
| 373 | var env map[string]any |
| 374 | if err := json.Unmarshal(raw, &env); err != nil { |
| 375 | t.Fatalf("envelope is not valid JSON: %v\n%s", err, raw) |
| 376 | } |
| 377 | errObj, ok := env["error"].(map[string]any) |
| 378 | if !ok { |
| 379 | t.Fatalf("envelope missing top-level error object: %s", raw) |
| 380 | } |
| 381 | return errObj |
| 382 | } |
| 383 | |
| 384 | // TestHandleRootError_NoDeprecationTypesUsageError pins that a residual cobra |
| 385 | // usage error (missing required flag) is typed as invalid_argument with exit 2 |
no outgoing calls
no test coverage detected