MCPcopy Index your code
hub / github.com/chain/txvm / TestData

Function TestData

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

Source from the content-addressed store, hash-verified

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