MCPcopy Create free account
hub / github.com/chain/Core / TestDetail

Function TestDetail

errors/errors_test.go:74–98  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

72}
73
74func TestDetail(t *testing.T) {
75 root := errors.New("foo")
76 cases := []struct {
77 err error
78 detail string
79 message string
80 }{
81 {root, "", "foo"},
82 {WithDetail(root, "bar"), "bar", "bar: foo"},
83 {WithDetail(WithDetail(root, "bar"), "baz"), "bar; baz", "baz: bar: foo"},
84 {Wrap(WithDetail(root, "bar"), "baz"), "bar", "baz: bar: foo"},
85 }
86
87 for _, test := range cases {
88 if got := Detail(test.err); got != test.detail {
89 t.Errorf("Detail(%v) = %v want %v", test.err, got, test.detail)
90 }
91 if got := Root(test.err); got != root {
92 t.Errorf("Root(%v) = %v want %v", test.err, got, root)
93 }
94 if got := test.err.Error(); got != test.message {
95 t.Errorf("(%v).Error() = %v want %v", test.err, got, test.message)
96 }
97 }
98}
99
100func TestData(t *testing.T) {
101 root := errors.New("foo")

Callers

nothing calls this directly

Calls 5

WithDetailFunction · 0.85
WrapFunction · 0.85
DetailFunction · 0.85
RootFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected