1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-26 05:15:56 +00:00
Former-commit-id: 55589069c8ed458183d28f32870fdf8f233629c6
This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-07-11 16:14:31 +03:00
parent 3574816e1d
commit c8ed26ee51
8 changed files with 981 additions and 923 deletions

View File

@@ -258,3 +258,24 @@ func TestPreflightResult(t *testing.T) {
e.POST("/alternative").WithJSON(testInput{expected4.Name}).
Expect().Status(httptest.StatusAccepted).JSON().Equal(expected4)
}
func TestResponseErr(t *testing.T) {
app := iris.New()
var expectedErr = errors.New("response error")
app.OnAnyErrorCode(func(ctx iris.Context) {
err := ctx.GetErr()
if err != expectedErr {
t.Fatalf("expected error value does not match")
}
ctx.WriteString(err.Error())
})
app.ConfigureContainer().Get("/", func() Response {
return Response{Code: iris.StatusBadGateway, Err: expectedErr}
})
e := httptest.New(t, app)
e.GET("/").Expect().Status(iris.StatusBadGateway).Body().Equal("response error")
}