mirror of
https://github.com/kataras/iris.git
synced 2025-12-18 10:27:06 +00:00
HandleHTTPError MVC Method as requested at #1595. Read HISTORY.md
example at: https://github.com/kataras/iris/tree/master/_examples/mvc/error-handler-http
This commit is contained in:
20
_examples/mvc/error-handler-http/main_test.go
Normal file
20
_examples/mvc/error-handler-http/main_test.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/kataras/iris/v12/httptest"
|
||||
)
|
||||
|
||||
func TestControllerHandleHTTPError(t *testing.T) {
|
||||
const (
|
||||
expectedIndex = "Hello!"
|
||||
expectedNotFound = "<h3>Not Found Custom Page Rendered through Controller's HandleHTTPError</h3>"
|
||||
)
|
||||
|
||||
app := newApp()
|
||||
|
||||
e := httptest.New(t, app)
|
||||
e.GET("/").Expect().Status(httptest.StatusOK).Body().Equal(expectedIndex)
|
||||
e.GET("/a_notefound").Expect().Status(httptest.StatusNotFound).ContentType("text/html").Body().Equal(expectedNotFound)
|
||||
}
|
||||
Reference in New Issue
Block a user