This test demonstrates that two errors that are structurally equivalent can be made to become non-equivalent through markers.Is() by using markers.
(t *testing.T)
| 388 | // equivalent can be made to become non-equivalent through markers.Is() |
| 389 | // by using markers. |
| 390 | func TestMarkerDrivenDifference(t *testing.T) { |
| 391 | tt := testutils.T{T: t} |
| 392 | |
| 393 | err1 := errors.New("hello") |
| 394 | err2 := errors.New("hello") |
| 395 | |
| 396 | tt.Check(markers.Is(err1, err2)) |
| 397 | |
| 398 | m1 := errors.New("m1") |
| 399 | m2 := errors.New("m2") |
| 400 | |
| 401 | err1w := markers.Mark(err1, m1) |
| 402 | err2w := markers.Mark(err2, m2) |
| 403 | |
| 404 | tt.Check(markers.Is(err1w, m1)) |
| 405 | tt.Check(markers.Is(err2w, m2)) |
| 406 | |
| 407 | tt.Check(!markers.Is(err1w, err2w)) |
| 408 | } |
| 409 | |
| 410 | // This test demonstrates that error differences introduced |
| 411 | // via Mark() are preserved across the network. |