MCPcopy Create free account
hub / github.com/devfeel/dotweb / TestBinder_Bind_default_error

Function TestBinder_Bind_default_error

bind_test.go:255–302  ·  view source on GitHub ↗

else

(t *testing.T)

Source from the content-addressed store, hash-verified

253
254// else
255func TestBinder_Bind_default_error(t *testing.T) {
256
257 binder := newBinder()
258
259 if binder == nil {
260 t.Error("binder can not be nil!")
261 }
262
263 // init DotServer
264 app := New()
265
266 if app == nil {
267 t.Error("app can not be nil!")
268 }
269
270 // expected
271 expected := &Person{
272 Hair: "Brown",
273 HasGlass: true,
274 Age: 10,
275 Legs: []string{"Left", "Right"},
276 }
277 param := &InitContextParam{
278 t,
279 expected,
280 "application/xml",
281 test.ToDefault,
282 }
283
284 // init param
285 context := initContext(param)
286
287 form := make(map[string][]string)
288 form["Hair"] = []string{"Brown"}
289 form["HasGlass"] = []string{"true"}
290 form["Age"] = []string{"10"}
291 form["Legs"] = []string{"Left", "Right"}
292
293 context.request.Form = form
294 // actual
295 person := &Person{}
296
297 err := binder.Bind(person, context)
298
299 // check error must not nil
300 test.NotNil(t, err)
301
302}
303
304// default
305// TODO:content type is null but body not null,is it right??

Callers

nothing calls this directly

Calls 6

NotNilFunction · 0.92
newBinderFunction · 0.85
NewFunction · 0.85
initContextFunction · 0.85
ErrorMethod · 0.65
BindMethod · 0.65

Tested by

no test coverage detected