1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 10:27:06 +00:00
Gerasimos (Makis) Maropoulos
2020-03-24 02:12:10 +02:00
parent 0d3770380f
commit a694266c63
3 changed files with 41 additions and 1 deletions

View File

@@ -585,3 +585,42 @@ func TestControllerRequestScopedDependencies(t *testing.T) {
})
e.GET("/custom/context").Expect().Status(httptest.StatusOK).Body().Equal("test")
}
type (
testServiceDoSomething struct{}
TestControllerAsDeepDep struct {
Ctx iris.Context
Service *testServiceDoSomething
}
FooController struct {
TestControllerAsDeepDep
}
BarController struct {
FooController
}
FinalController struct {
BarController
}
)
func (s *testServiceDoSomething) DoSomething(ctx iris.Context) {
ctx.WriteString("foo bar")
}
func (c *FinalController) GetSomething() {
c.Service.DoSomething(c.Ctx)
}
func TestControllersInsideControllerDeep(t *testing.T) {
app := iris.New()
m := New(app)
m.Register(new(testServiceDoSomething))
m.Handle(new(FinalController))
e := httptest.New(t, app)
e.GET("/something").Expect().Status(httptest.StatusOK).Body().Equal("foo bar")
}