I have a below test:
package api_app
func (api *ApiResource) TestAuthenticate(t *testing.T) {
httpReq, _ := http.NewRequest("POST", "/login", nil)
req := restful.NewRequest(httpReq)
recorder := new(httptest.ResponseRecorder)
resp := restful.NewResponse(recorder)
api.Authenticate(req, resp)
if recorder.Code!= 404 {
t.Logf("Missing or wrong status code:%d", recorder.Code)
}
}
I want to test this function but when I do
go test api_app -v
The test never rungs this. I understand that's because I have receiver for the function.
Is there a way we can test this thing?
http.Transport{}?