2014-01-28 84 views
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? 
} 

回答

相關問題