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

Function TestControllerMethodResult

mvc/controller_method_result_test.go:70–103  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

68}
69
70func TestControllerMethodResult(t *testing.T) {
71 app := iris.New()
72 New(app).Handle(new(testControllerMethodResult))
73
74 e := httptest.New(t, app)
75
76 e.GET("/").Expect().Status(iris.StatusOK).
77 Body().IsEqual("Hello World!")
78
79 e.GET("/with/status").Expect().Status(iris.StatusNotFound).
80 Body().IsEqual("This page doesn't exist")
81
82 e.GET("/json").Expect().Status(iris.StatusOK).
83 JSON().IsEqual(iris.Map{
84 "name": "Iris",
85 "age": 2,
86 })
87
88 e.GET("/json").WithQuery("err", true).Expect().
89 Status(iris.StatusBadRequest).
90 Body().IsEqual("error here")
91
92 e.GET("/thing/with/try/1").Expect().
93 Status(iris.StatusOK).
94 Body().IsEqual("thing 1")
95 // failure because of index exceed the slice
96 e.GET("/thing/with/try/3").Expect().
97 Status(iris.StatusNotFound).
98 Body().IsEqual("thing does not exist")
99
100 e.GET("/thing/with/try/default/3").Expect().
101 Status(iris.StatusBadRequest).
102 Body().IsEqual("Bad Request")
103}
104
105type testControllerMethodResultTypes struct {
106 Ctx *context.Context

Callers

nothing calls this directly

Calls 7

NewFunction · 0.92
NewMethod · 0.80
StatusMethod · 0.80
NewFunction · 0.70
HandleMethod · 0.65
BodyMethod · 0.65
JSONMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…