mirror of
https://github.com/astaxie/beego.git
synced 2024-11-25 21:51:28 +00:00
go fmt error_test.go
This commit is contained in:
parent
1a401af23b
commit
5858607f49
@ -26,10 +26,12 @@ type errorTestController struct {
|
|||||||
Controller
|
Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const parseCodeError = "parse code error"
|
||||||
|
|
||||||
func (ec *errorTestController) Get() {
|
func (ec *errorTestController) Get() {
|
||||||
errorCode, err := ec.GetInt("code")
|
errorCode, err := ec.GetInt("code")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ec.Abort("parse code error")
|
ec.Abort(parseCodeError)
|
||||||
}
|
}
|
||||||
if errorCode != 0 {
|
if errorCode != 0 {
|
||||||
ec.CustomAbort(errorCode, ec.GetString("code"))
|
ec.CustomAbort(errorCode, ec.GetString("code"))
|
||||||
@ -66,13 +68,12 @@ func TestErrorCode_02(t *testing.T) {
|
|||||||
handler.ServeHTTP(w, r)
|
handler.ServeHTTP(w, r)
|
||||||
if w.Code != 404 {
|
if w.Code != 404 {
|
||||||
t.Fail()
|
t.Fail()
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestErrorCode_03(t *testing.T) {
|
func TestErrorCode_03(t *testing.T) {
|
||||||
registerDefaultErrorHandler()
|
registerDefaultErrorHandler()
|
||||||
r, _ := http.NewRequest("GET", "/error?code=crash", nil)
|
r, _ := http.NewRequest("GET", "/error?code=panic", nil)
|
||||||
w := httptest.NewRecorder()
|
w := httptest.NewRecorder()
|
||||||
|
|
||||||
handler := NewControllerRegister()
|
handler := NewControllerRegister()
|
||||||
@ -81,7 +82,7 @@ func TestErrorCode_03(t *testing.T) {
|
|||||||
if w.Code != 200 {
|
if w.Code != 200 {
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
if string(w.Body.Bytes()) != "parse code error" {
|
if string(w.Body.Bytes()) != parseCodeError {
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user