1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 13:20:55 +00:00

go fmt error_test.go

This commit is contained in:
JessonChan 2016-03-22 18:32:14 +08:00
parent 1a401af23b
commit 5858607f49

View File

@ -26,10 +26,12 @@ type errorTestController struct {
Controller
}
const parseCodeError = "parse code error"
func (ec *errorTestController) Get() {
errorCode, err := ec.GetInt("code")
if err != nil {
ec.Abort("parse code error")
ec.Abort(parseCodeError)
}
if errorCode != 0 {
ec.CustomAbort(errorCode, ec.GetString("code"))
@ -66,13 +68,12 @@ func TestErrorCode_02(t *testing.T) {
handler.ServeHTTP(w, r)
if w.Code != 404 {
t.Fail()
}
}
func TestErrorCode_03(t *testing.T) {
registerDefaultErrorHandler()
r, _ := http.NewRequest("GET", "/error?code=crash", nil)
r, _ := http.NewRequest("GET", "/error?code=panic", nil)
w := httptest.NewRecorder()
handler := NewControllerRegister()
@ -81,7 +82,7 @@ func TestErrorCode_03(t *testing.T) {
if w.Code != 200 {
t.Fail()
}
if string(w.Body.Bytes()) != "parse code error" {
if string(w.Body.Bytes()) != parseCodeError {
t.Fail()
}
}