~fwereade/pyjuju/go-log-type

« back to all changes in this revision

Viewing changes to cmd/jujud/machine_test.go

  • Committer: William Reade
  • Author(s): William Reade
  • Date: 2012-02-17 09:22:47 UTC
  • mfrom: (61.1.1 go)
  • Revision ID: fwereade@gmail.com-20120217092247-bs9zhqak1w3uzkzr
add jujud command (with subcommands initzk, unit, machine, provisioning)

Moved some of cmd/juju into cmd, with some changes, for reuse by cmd/jujud;
added subcommands listed above. None of these commands actually do anything
yet; I'm waiting for the State connection work to stabilise a bit before I
hook this up.

It's interesting to note that SuperCommand (once JujuCommand) needs only a
little work before it can itself usefully Register further SuperCommands, but
there's no call for that at the moment (we'd need to add a managesLogging
field which, if unset, would block initOutput and prevent InitFlagSet from
trying to extend the subcommand, and set it only on the top-level command).

The various agent types now implement cmd.Command by embedding agentConf;
and, indeed, it's even nicer like this :).

R=rog, niemeyer
CC=
https://codereview.appspot.com/5642048

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package main_test
 
2
 
 
3
import (
 
4
        . "launchpad.net/gocheck"
 
5
        main "launchpad.net/juju/go/cmd/jujud"
 
6
)
 
7
 
 
8
type MachineSuite struct{}
 
9
 
 
10
var _ = Suite(&MachineSuite{})
 
11
 
 
12
func (s *MachineSuite) TestParseSuccess(c *C) {
 
13
        create := func() main.AgentCommand { return main.NewMachineAgent() }
 
14
        a := CheckAgentCommand(c, create, []string{"--machine-id", "42"})
 
15
        c.Assert(a.(*main.MachineAgent).MachineId, Equals, 42)
 
16
}
 
17
 
 
18
func (s *MachineSuite) TestParseNonsense(c *C) {
 
19
        for _, args := range [][]string{
 
20
                []string{},
 
21
                []string{"--machine-id", "-4004"},
 
22
        } {
 
23
                err := ParseAgentCommand(main.NewMachineAgent(), args)
 
24
                c.Assert(err, ErrorMatches, "--machine-id option must be set, and expects a non-negative integer")
 
25
        }
 
26
}
 
27
 
 
28
func (s *MachineSuite) TestParseUnknown(c *C) {
 
29
        a := main.NewMachineAgent()
 
30
        err := ParseAgentCommand(a, []string{"--machine-id", "42", "blistering barnacles"})
 
31
        c.Assert(err, ErrorMatches, `unrecognised args: \[blistering barnacles\]`)
 
32
}