mirror of
https://github.com/kataras/iris.git
synced 2025-12-17 18:07:01 +00:00
add a test for controller.GetBy-only method... it passes as expected https://github.com/kataras/iris/issues/1487
Former-commit-id: 5f4abd4a8c6528d666d91315fa515a4a607326fc
This commit is contained in:
@@ -175,3 +175,24 @@ func TestControllerHandleWithDynamicPathPrefix(t *testing.T) {
|
||||
e.GET("/api/data/mymodel/myaction/myid").Expect().Status(httptest.StatusOK).
|
||||
Body().Equal("mymodelmyactionmyid")
|
||||
}
|
||||
|
||||
type testControllerGetBy struct{}
|
||||
|
||||
func (c *testControllerGetBy) GetBy(age int64) *testCustomStruct {
|
||||
return &testCustomStruct{
|
||||
Age: int(age),
|
||||
Name: "name",
|
||||
}
|
||||
}
|
||||
|
||||
func TestControllerGetBy(t *testing.T) {
|
||||
// Tests only GetBy.
|
||||
app := iris.New()
|
||||
app.Configure(iris.WithFireMethodNotAllowed)
|
||||
|
||||
New(app.Party("/project")).Handle(new(testControllerGetBy))
|
||||
e := httptest.New(t, app)
|
||||
e.GET("/project/42").Expect().Status(httptest.StatusOK).
|
||||
JSON().Equal(&testCustomStruct{Age: 42, Name: "name"})
|
||||
e.POST("/project/42").Expect().Status(httptest.StatusMethodNotAllowed)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user