当您返回 500 服务器错误时,如何使用 httptest 获取错误消息?手动测试时注册页面有效,所以这似乎是一些管道问题,但我找不到消息是什么。func TestSignUp(t *testing.T) { var ( password = "password" ) newUser := entities.User{} newUser.Email = "j@doe.co.za" 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?}
1 回答
- 1 回答
- 0 关注
- 232 浏览
添加回答
举报
0/150
提交
取消