func (s *statusSuite) TestValidateStateOkay(c *gc.C) { for _, state := range okayStates { c.Logf("checking %q", state) err := payload.ValidateState(state) c.Check(err, jc.ErrorIsNil) } }
// SetStatus updates the raw status for the identified payload to the // provided value. If the payload is missing then payload.ErrNotFound // is returned. func (up UnitPayloads) SetStatus(name, status string) error { if err := payload.ValidateState(status); err != nil { return errors.Trace(err) } change := payloadSetStatusChange{ Unit: up.unit, Name: name, Status: status, } if err := Apply(up.db, change); err != nil { return errors.Trace(err) } return nil }
// SetStatus updates the raw status for the identified payload to the // provided value. func (uw UnitPayloads) SetStatus(id, status string) error { logger.Tracef("setting payload status for %q to %q", id, status) if err := payload.ValidateState(status); err != nil { return errors.Trace(err) } found, err := uw.Persist.SetStatus(id, status) if err != nil { return errors.Trace(err) } if !found { return errors.NotFoundf(id) } return nil }
func (s *statusSuite) TestValidateStateBadState(c *gc.C) { state := "some bogus state" err := payload.ValidateState(state) c.Check(err, jc.Satisfies, errors.IsNotValid) }
func (s *statusSuite) TestValidateStateUndefined(c *gc.C) { var state string err := payload.ValidateState(state) c.Check(err, jc.Satisfies, errors.IsNotValid) }
func (c *StatusSetCmd) validate(ctx *cmd.Context) error { return payload.ValidateState(c.status) }