mirror of
https://github.com/kataras/iris.git
synced 2026-03-10 02:16:10 +00:00
Update to version 8.5.1. It contains a minor fix. Read HISTORY.md
https://github.com/kataras/iris/blob/master/HISTORY.md#tu-10-october-2017--v851 Former-commit-id: af1424c691613ccde911bef7d1371aa52e6abb79
This commit is contained in:
@@ -222,3 +222,50 @@ func TestControllerMethodResultTypes(t *testing.T) {
|
||||
// it will fire the error's text
|
||||
Body().Equal("omit return of testCustomStruct and fire error")
|
||||
}
|
||||
|
||||
type testControllerViewResultRespectCtxViewData struct {
|
||||
T *testing.T
|
||||
mvc.C
|
||||
}
|
||||
|
||||
func (t *testControllerViewResultRespectCtxViewData) BeginRequest(ctx context.Context) {
|
||||
t.C.BeginRequest(ctx)
|
||||
ctx.ViewData("name_begin", "iris_begin")
|
||||
}
|
||||
|
||||
func (t *testControllerViewResultRespectCtxViewData) EndRequest(ctx context.Context) {
|
||||
t.C.EndRequest(ctx)
|
||||
// check if data is not overriden by return mvc.View {Data: context.Map...}
|
||||
|
||||
dataWritten := ctx.GetViewData()
|
||||
if dataWritten == nil {
|
||||
t.T.Fatalf("view data is nil, both BeginRequest and Get failed to write the data")
|
||||
return
|
||||
}
|
||||
|
||||
if dataWritten["name_begin"] == nil {
|
||||
t.T.Fatalf(`view data[name_begin] is nil,
|
||||
BeginRequest's ctx.ViewData call have been overriden by Get's return mvc.View {Data: }.
|
||||
Total view data: %v`, dataWritten)
|
||||
}
|
||||
|
||||
if dataWritten["name"] == nil {
|
||||
t.T.Fatalf("view data[name] is nil, Get's return mvc.View {Data: } didn't work. Total view data: %v", dataWritten)
|
||||
}
|
||||
}
|
||||
|
||||
func (t *testControllerViewResultRespectCtxViewData) Get() mvc.Result {
|
||||
return mvc.View{
|
||||
Name: "doesnt_exists.html",
|
||||
Data: context.Map{"name": "iris"}, // we care about this only.
|
||||
Code: iris.StatusInternalServerError,
|
||||
}
|
||||
}
|
||||
|
||||
func TestControllerViewResultRespectCtxViewData(t *testing.T) {
|
||||
app := iris.New()
|
||||
app.Controller("/", new(testControllerViewResultRespectCtxViewData), t)
|
||||
e := httptest.New(t, app)
|
||||
|
||||
e.GET("/").Expect().Status(iris.StatusInternalServerError)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user