예제 #1
0
func (s *responseSuite) TestExtractAPIErrorFailure(c *gc.C) {
	original := &params.Error{
		Message: "something went wrong!",
	}
	response := apihttptesting.NewFailureResponse(original)
	failure, err := apihttp.ExtractAPIError(&response.Response)
	c.Assert(err, jc.ErrorIsNil)

	c.Check(failure, gc.Not(gc.Equals), original)
	c.Check(failure, gc.DeepEquals, original)
}
예제 #2
0
func (s *responseSuite) TestExtractAPIErrorWrongContentType(c *gc.C) {
	original := &params.Error{
		Message: "something went wrong!",
	}
	response := apihttptesting.NewFailureResponse(original)
	response.Header.Del("Content-Type")
	failure, err := apihttp.ExtractAPIError(&response.Response)
	c.Assert(err, jc.ErrorIsNil)

	c.Check(failure.Message, gc.Equals, `{"Message":"something went wrong!","Code":""}`+"\n")
	c.Check(failure.Code, gc.Equals, "")
}