(t *testing.T)
| 146 | } |
| 147 | |
| 148 | func TestAdaptPkgWithStack(t *testing.T) { |
| 149 | // The "with stack" wrapper from github.com/pkg/errors cannot be |
| 150 | // serialized exactly, however we are happy to preserve this stack |
| 151 | // trace. |
| 152 | origErr := pkgErr.WithStack(goErr.New("hello")) |
| 153 | t.Logf("start err: %# v", pretty.Formatter(origErr)) |
| 154 | |
| 155 | tt := testutils.T{T: t} |
| 156 | // Show that there is indeed a stack trace. |
| 157 | theStack := fmt.Sprintf("%+v", errbase.GetSafeDetails(origErr)) |
| 158 | tt.Check(strings.Contains(theStack, "adapters_test.go")) |
| 159 | |
| 160 | newErr := network(t, origErr) |
| 161 | |
| 162 | // In any case, the library preserves the error message. |
| 163 | tt.CheckEqual(newErr.Error(), origErr.Error()) |
| 164 | |
| 165 | // The decoded error does not compare equal, since |
| 166 | // we had to change the type to preserve the stack trace. |
| 167 | tt.Check(!reflect.DeepEqual(newErr, origErr)) |
| 168 | |
| 169 | // However, it does include the stack trace. |
| 170 | details := errbase.GetSafeDetails(newErr).SafeDetails |
| 171 | tt.Check(len(details) > 0 && strings.Contains(details[0], "adapters_test.go")) |
| 172 | |
| 173 | // Moreover, if we re-encode and re-decode, that will be preserved exactly! |
| 174 | newErr2 := network(t, newErr) |
| 175 | tt.CheckDeepEqual(newErr2, newErr) |
| 176 | } |
| 177 | |
| 178 | func TestAdaptProtoErrors(t *testing.T) { |
| 179 | // If an error type has a proto representation already, |
nothing calls this directly
no test coverage detected
searching dependent graphs…