Ejemplo n.º 1
0
func (s *responseSuite) TestExtractAPIErrorMethodNotAllowed(c *gc.C) {
	response := apihttptesting.NewErrorResponse(http.StatusMethodNotAllowed, "something went wrong!")
	failure, err := apihttp.ExtractAPIError(&response.Response)
	c.Assert(err, jc.ErrorIsNil)

	c.Check(failure.Message, gc.Equals, "something went wrong!")
	c.Check(failure.Code, gc.Equals, params.CodeNotImplemented)
}
Ejemplo n.º 2
0
func (s *responseSuite) TestExtractAPIErrorString(c *gc.C) {
	response := apihttptesting.NewErrorResponse(http.StatusInternalServerError, "something went wrong!")
	failure, err := apihttp.ExtractAPIError(&response.Response)
	c.Assert(err, jc.ErrorIsNil)

	c.Check(failure.Message, gc.Equals, "something went wrong!")
	c.Check(failure.Code, gc.Equals, "")
}