1
当您收到500服务器错误时,如何通过httptest获取错误消息? 注册页面在手动测试时工作,所以这似乎是一些管道问题,但我找不到什么信息。Golang通过httptest失败获取错误消息
func TestSignUp(t *testing.T) {
var (
password = "password"
)
newUser := entities.User{}
newUser.Email = "[email protected]"
newUser.SetPassword(password, bcrypt.MinCost)
v := url.Values{}
v.Add("email_address", newUser.Email)
v.Add("password", password)
res := httptest.NewRecorder()
req := &http.Request{
Method: "POST",
URL: &url.URL{Path: "/signup"},
Form: v,
}
m := Martini()
m.ServeHTTP(res, req)
assert.Equal(t, 200, res.Code) <<<< res.Code = 500, but where is the error message?
}