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

Function TestData

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

Source from the content-addressed store, hash-verified

98}
99
100func TestData(t *testing.T) {
101 root := errors.New("foo")
102 cases := []struct {
103 err error
104 data interface{}
105 }{
106 {WithData(root, "a", "b"), map[string]interface{}{"a": "b"}},
107 {WithData(WithData(root, "a", "b"), "c", "d"), map[string]interface{}{"a": "b", "c": "d"}},
108 {Wrap(WithData(root, "a", "b"), "baz"), map[string]interface{}{"a": "b"}},
109 }
110
111 for _, test := range cases {
112 if got := Data(test.err); !reflect.DeepEqual(got, test.data) {
113 t.Errorf("Data(%#v) = %v want %v", test.err, got, test.data)
114 }
115 if got := Root(test.err); got != root {
116 t.Errorf("Root(%#v) = %v want %v", test.err, got, root)
117 }
118 }
119}
120
121func TestSub(t *testing.T) {
122 x := errors.New("x")

Callers

nothing calls this directly

Calls 4

WithDataFunction · 0.85
WrapFunction · 0.85
DataFunction · 0.70
RootFunction · 0.70

Tested by

no test coverage detected