~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/payload/status_test.go

  • Committer: Nicholas Skaggs
  • Date: 2016-10-24 20:56:05 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161024205605-z8lta0uvuhtxwzwl
Initi with beta15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2015 Canonical Ltd.
 
2
// Licensed under the AGPLv3, see LICENCE file for details.
 
3
 
 
4
package payload_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/payload"
 
12
        "github.com/juju/juju/testing"
 
13
)
 
14
 
 
15
var (
 
16
        okayStates = []string{
 
17
                payload.StateStarting,
 
18
                payload.StateRunning,
 
19
                payload.StateStopping,
 
20
                payload.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 := payload.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 := payload.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 := payload.ValidateState(state)
 
49
 
 
50
        c.Check(err, jc.Satisfies, errors.IsNotValid)
 
51
}