MCPcopy
hub / github.com/mitchellh/mapstructure / TestOrComposeDecodeHookFunc_err

Function TestOrComposeDecodeHookFunc_err

decode_hooks_test.go:148–173  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

146}
147
148func TestOrComposeDecodeHookFunc_err(t *testing.T) {
149 f1 := func(
150 f reflect.Kind,
151 t reflect.Kind,
152 data interface{}) (interface{}, error) {
153 return nil, errors.New("f1 error")
154 }
155
156 f2 := func(
157 f reflect.Kind,
158 t reflect.Kind,
159 data interface{}) (interface{}, error) {
160 return nil, errors.New("f2 error")
161 }
162
163 f := OrComposeDecodeHookFunc(f1, f2)
164
165 _, err := DecodeHookExec(
166 f, reflect.ValueOf(""), reflect.ValueOf([]byte("")))
167 if err == nil {
168 t.Fatalf("bad: should return an error")
169 }
170 if err.Error() != "f1 error\nf2 error\n" {
171 t.Fatalf("bad: %s", err)
172 }
173}
174
175func TestComposeDecodeHookFunc_safe_nofuncs(t *testing.T) {
176 f := ComposeDecodeHookFunc()

Callers

nothing calls this directly

Calls 3

OrComposeDecodeHookFuncFunction · 0.85
DecodeHookExecFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…