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

Function TestControllerGetByWithAllowMethods

mvc/controller_handle_test.go:188–201  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

186}
187
188func TestControllerGetByWithAllowMethods(t *testing.T) {
189 app := iris.New()
190 app.Configure(iris.WithFireMethodNotAllowed)
191 // ^ this 405 status will not be fired on POST: project/... because of
192 // .AllowMethods, but it will on PUT.
193
194 New(app.Party("/project").AllowMethods(iris.MethodGet, iris.MethodPost)).Handle(new(testControllerGetBy))
195
196 e := httptest.New(t, app)
197 e.GET("/project/42").Expect().Status(httptest.StatusOK).
198 JSON().IsEqual(&testCustomStruct{Age: 42, Name: "name"})
199 e.POST("/project/42").Expect().Status(httptest.StatusOK)
200 e.PUT("/project/42").Expect().Status(httptest.StatusMethodNotAllowed)
201}

Callers

nothing calls this directly

Calls 9

NewFunction · 0.92
NewMethod · 0.80
StatusMethod · 0.80
NewFunction · 0.70
ConfigureMethod · 0.65
HandleMethod · 0.65
AllowMethodsMethod · 0.65
PartyMethod · 0.65
JSONMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…