github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/core/payloads/status_test.go (about) 1 // Copyright 2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package payloads_test 5 6 import ( 7 "github.com/juju/errors" 8 jc "github.com/juju/testing/checkers" 9 gc "gopkg.in/check.v1" 10 11 "github.com/juju/juju/core/payloads" 12 "github.com/juju/juju/testing" 13 ) 14 15 var ( 16 okayStates = []string{ 17 payloads.StateStarting, 18 payloads.StateRunning, 19 payloads.StateStopping, 20 payloads.StateStopped, 21 } 22 ) 23 24 type statusSuite struct { 25 testing.BaseSuite 26 } 27 28 var _ = gc.Suite(&statusSuite{}) 29 30 func (s *statusSuite) TestValidateStateOkay(c *gc.C) { 31 for _, state := range okayStates { 32 c.Logf("checking %q", state) 33 err := payloads.ValidateState(state) 34 35 c.Check(err, jc.ErrorIsNil) 36 } 37 } 38 39 func (s *statusSuite) TestValidateStateUndefined(c *gc.C) { 40 var state string 41 err := payloads.ValidateState(state) 42 43 c.Check(err, jc.Satisfies, errors.IsNotValid) 44 } 45 46 func (s *statusSuite) TestValidateStateBadState(c *gc.C) { 47 state := "some bogus state" 48 err := payloads.ValidateState(state) 49 50 c.Check(err, jc.Satisfies, errors.IsNotValid) 51 }