MCPcopy Create free account
hub / github.com/cockroachdb/errors / TestLocalLocalEquivalence

Function TestLocalLocalEquivalence

markers/markers_test.go:475–505  ·  view source on GitHub ↗

This test is used in the RFC.

(t *testing.T)

Source from the content-addressed store, hash-verified

473
474// This test is used in the RFC.
475func TestLocalLocalEquivalence(t *testing.T) {
476 tt := testutils.T{T: t}
477
478 err1 := errors.New("hello")
479 err2 := errors.New("hello")
480 err3 := errors.New("world")
481
482 // Different errors are different via markers.Is().
483 tt.Check(!markers.Is(err1, err3))
484
485 // Errors are equivalent to themselves.
486 tt.Check(markers.Is(err1, err1))
487 tt.Check(markers.Is(err2, err2))
488 tt.Check(markers.Is(err3, err3))
489
490 m := errors.New("mark")
491 err1w := markers.Mark(err1, m)
492 err3w := markers.Mark(err3, m)
493
494 // Shared marks introduce explicit equivalence.
495 tt.Check(markers.Is(err1w, m))
496 tt.Check(markers.Is(err3w, m))
497 tt.Check(markers.Is(err3w, err1w))
498
499 m2 := errors.New("m2")
500 err2w := markers.Mark(err2, m2)
501
502 // Different marks introduce explicit non-equivalence,
503 // even when the underlying errors are equivalent.
504 tt.Check(!markers.Is(err2w, err1w))
505}
506
507// This test is used in the RFC.
508func TestLocalRemoteEquivalence(t *testing.T) {

Callers

nothing calls this directly

Calls 3

CheckMethod · 0.95
IsFunction · 0.92
MarkFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…