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

Function TestDetail

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected