MCPcopy Create free account
hub / github.com/kataras/iris / TestControllerMethodHandlerBindStruct

Function TestControllerMethodHandlerBindStruct

mvc/controller_test.go:690–710  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

688}
689
690func TestControllerMethodHandlerBindStruct(t *testing.T) {
691 app := iris.New()
692
693 m := New(app.Party("/data"))
694 m.HandleError(func(ctx iris.Context, err error) {
695 t.Fatalf("Path: %s, Error: %v", ctx.Path(), err)
696 })
697
698 m.Handle(new(testControllerMethodHandlerBindStruct))
699
700 data := bindStructData{Name: "kataras"}
701 manyData := []bindStructData{data, {"john doe"}}
702
703 e := httptest.New(t, app)
704 e.GET("/data").WithQueryObject(data).Expect().Status(httptest.StatusOK).JSON().IsEqual(data)
705 e.PATCH("/data").WithJSON(data).Expect().Status(httptest.StatusOK).JSON().IsEqual(data)
706 e.POST("/data/42/slice").WithJSON(manyData).Expect().Status(httptest.StatusOK).JSON().IsEqual(manyData)
707 e.POST("/data/42/slicetype").WithJSON(manyData).Expect().Status(httptest.StatusOK).JSON().IsEqual(manyData)
708 e.POST("/data/42/slicetypeptr").WithJSON(manyData).Expect().Status(httptest.StatusOK).JSON().IsEqual(manyData)
709 // more tests inside the hero package itself.
710}
711
712func TestErrorHandlerContinue(t *testing.T) {
713 app := iris.New()

Callers

nothing calls this directly

Calls 10

NewFunction · 0.92
NewMethod · 0.80
FatalfMethod · 0.80
StatusMethod · 0.80
NewFunction · 0.70
PartyMethod · 0.65
HandleErrorMethod · 0.65
PathMethod · 0.65
HandleMethod · 0.65
JSONMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…