~fwereade/pyjuju/go-place-unit

« back to all changes in this revision

Viewing changes to cmd/jujud/unit_test.go

  • Committer: William Reade
  • Date: 2012-06-06 09:57:29 UTC
  • mfrom: (193.1.10 go)
  • Revision ID: fwereade@gmail.com-20120606095729-gvsqo1auqspzog9j
merge parent

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package main_test
 
1
package main
2
2
 
3
3
import (
4
4
        . "launchpad.net/gocheck"
5
5
        "launchpad.net/juju/go/cmd"
6
 
        main "launchpad.net/juju/go/cmd/jujud"
7
6
)
8
7
 
9
8
type UnitSuite struct{}
11
10
var _ = Suite(&UnitSuite{})
12
11
 
13
12
func (s *UnitSuite) TestParseSuccess(c *C) {
14
 
        create := func() (cmd.Command, *main.AgentConf) {
15
 
                a := &main.UnitAgent{}
 
13
        create := func() (cmd.Command, *AgentConf) {
 
14
                a := &UnitAgent{}
16
15
                return a, &a.Conf
17
16
        }
18
17
        uc := CheckAgentCommand(c, create, []string{"--unit-name", "w0rd-pre55/1"})
19
 
        c.Assert(uc.(*main.UnitAgent).UnitName, Equals, "w0rd-pre55/1")
 
18
        c.Assert(uc.(*UnitAgent).UnitName, Equals, "w0rd-pre55/1")
20
19
}
21
20
 
22
21
func (s *UnitSuite) TestParseMissing(c *C) {
23
 
        uc := &main.UnitAgent{}
 
22
        uc := &UnitAgent{}
24
23
        err := ParseAgentCommand(uc, []string{})
25
24
        c.Assert(err, ErrorMatches, "--unit-name option must be set")
26
25
}
33
32
                []string{"--unit-name", "wordpress/wild/9"},
34
33
                []string{"--unit-name", "20/20"},
35
34
        } {
36
 
                err := ParseAgentCommand(&main.UnitAgent{}, args)
 
35
                err := ParseAgentCommand(&UnitAgent{}, args)
37
36
                c.Assert(err, ErrorMatches, `--unit-name option expects "<service>/<n>" argument`)
38
37
        }
39
38
}
40
39
 
41
40
func (s *UnitSuite) TestParseUnknown(c *C) {
42
 
        uc := &main.UnitAgent{}
 
41
        uc := &UnitAgent{}
43
42
        err := ParseAgentCommand(uc, []string{"--unit-name", "wordpress/1", "thundering typhoons"})
44
43
        c.Assert(err, ErrorMatches, `unrecognized args: \["thundering typhoons"\]`)
45
44
}