forked from juju/juju
-
Notifications
You must be signed in to change notification settings - Fork 0
/
status_test.go
51 lines (39 loc) · 1.01 KB
/
status_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright 2015 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package payload_test
import (
"github.com/juju/errors"
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
"github.com/juju/juju/payload"
"github.com/juju/juju/testing"
)
var (
okayStates = []string{
payload.StateStarting,
payload.StateRunning,
payload.StateStopping,
payload.StateStopped,
}
)
type statusSuite struct {
testing.BaseSuite
}
var _ = gc.Suite(&statusSuite{})
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)
}
}
func (s *statusSuite) TestValidateStateUndefined(c *gc.C) {
var state string
err := payload.ValidateState(state)
c.Check(err, jc.Satisfies, errors.IsNotValid)
}
func (s *statusSuite) TestValidateStateBadState(c *gc.C) {
state := "some bogus state"
err := payload.ValidateState(state)
c.Check(err, jc.Satisfies, errors.IsNotValid)
}