TestMarkRawUnwrapsToInnerTypedError pins the envelope-serialization contract: UnwrapTypedError must return the inner concrete typed error, not the rawPassthrough wrapper. The wrapper has no exported fields, so if it were returned the JSON envelope would marshal to an empty "{}" error.
(t *testing.T)
| 78 | // not the rawPassthrough wrapper. The wrapper has no exported fields, so if it |
| 79 | // were returned the JSON envelope would marshal to an empty "{}" error. |
| 80 | func TestMarkRawUnwrapsToInnerTypedError(t *testing.T) { |
| 81 | base := errs.NewValidationError(errs.SubtypeInvalidArgument, "bad flag") |
| 82 | typed, ok := errs.UnwrapTypedError(errs.MarkRaw(base)) |
| 83 | if !ok { |
| 84 | t.Fatal("UnwrapTypedError(MarkRaw(typed)) must find a typed error") |
| 85 | } |
| 86 | out, err := json.Marshal(typed) |
| 87 | if err != nil { |
| 88 | t.Fatal(err) |
| 89 | } |
| 90 | if string(out) == "{}" { |
| 91 | t.Fatalf("UnwrapTypedError returned the opaque rawPassthrough wrapper; envelope would be empty: %s", out) |
| 92 | } |
| 93 | if got := errs.CategoryOf(typed); got != errs.CategoryValidation { |
| 94 | t.Fatalf("unwrapped category = %q, want validation", got) |
| 95 | } |
| 96 | } |
nothing calls this directly
no test coverage detected