func (s *responseSuite) TestExtractAPIErrorFailure(c *gc.C) { original := ¶ms.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) }
func (s *responseSuite) TestExtractAPIErrorWrongContentType(c *gc.C) { original := ¶ms.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, "") }