// Client should return ErrStatusBadRequest if entity doesn't validate func (s *TestSuite) TestSaveBadRequestFromEntity(c *C) { // given locClient := client.LocationClient{Host: s.host} location, _ := locClient.AddLocation("Austin", "Texas") // when location.State = "" _, err := locClient.SaveLocation(location) // then c.Assert(err, Equals, rest.ErrStatusBadRequest) }
// Client should return ErrStatusNotFound if trying to save to an id that doesn't exist func (s *TestSuite) TestSaveNotFound(c *C) { // given locClient := client.LocationClient{Host: s.host} location, _ := locClient.AddLocation("Austin", "Texas") // when location.Id = location.Id + 1 location.State = "foo" _, err := locClient.SaveLocation(location) // then c.Assert(err, Equals, rest.ErrStatusNotFound) }
// Save should update a location func (s *TestSuite) TestSave(c *C) { // given locClient := client.LocationClient{Host: s.host} location, _ := locClient.AddLocation("Austin", "Texas") // when saved, err := locClient.SaveLocation(location) // then c.Assert(err, Equals, nil) c.Assert(location.State, DeepEquals, saved.State) }