~dave-cheney/pyjuju/go-command-jujut

« back to all changes in this revision

Viewing changes to cmd/juju/cmd_test.go

  • Committer: Dave Cheney
  • Date: 2012-06-01 06:42:07 UTC
  • mfrom: (189.1.6 go)
  • Revision ID: david.cheney@canonical.com-20120601064207-jl5s9vax1pyg76vw
merge from tip and fix

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
        "io/ioutil"
5
5
        "launchpad.net/gnuflag"
6
6
        . "launchpad.net/gocheck"
7
7
        "launchpad.net/juju/go/cmd"
8
 
        main "launchpad.net/juju/go/cmd/juju"
9
8
        "launchpad.net/juju/go/environs"
10
9
        "launchpad.net/juju/go/environs/dummy"
11
10
        "launchpad.net/juju/go/testing"
87
86
// All members of EnvironmentInitTests are tested for the -environment and -e
88
87
// flags, and that extra arguments will cause parsing to fail.
89
88
var EnvironmentInitTests = []func() cmd.Command{
90
 
        func() cmd.Command { return new(main.BootstrapCommand) },
91
 
        func() cmd.Command { return new(main.DestroyCommand) },
 
89
        func() cmd.Command { return new(BootstrapCommand) },
 
90
        func() cmd.Command { return new(DestroyCommand) },
92
91
}
93
92
 
94
93
// TestEnvironmentInit tests that all commands which accept
137
136
 
138
137
func (*cmdSuite) TestBootstrapCommand(c *C) {
139
138
        // normal bootstrap
140
 
        opc, errc := runCommand(new(main.BootstrapCommand))
 
139
        opc, errc := runCommand(new(BootstrapCommand))
141
140
        c.Check(<-opc, Equals, op(dummy.OpBootstrap, "peckham"))
142
141
        c.Check(<-errc, IsNil)
143
142
 
144
143
        // bootstrap with tool uploading - checking that a file
145
144
        // is uploaded should be sufficient, as the detailed semantics
146
145
        // of UploadTools are tested in environs.
147
 
        opc, errc = runCommand(new(main.BootstrapCommand), "--upload-tools")
 
146
        opc, errc = runCommand(new(BootstrapCommand), "--upload-tools")
148
147
        c.Check(<-opc, Equals, op(dummy.OpPutFile, "peckham"))
149
148
        c.Check(<-opc, Equals, op(dummy.OpBootstrap, "peckham"))
150
149
        c.Check(<-errc, IsNil)
158
157
        c.Assert(err, IsNil)
159
158
 
160
159
        // bootstrap with broken environment
161
 
        opc, errc = runCommand(new(main.BootstrapCommand), "-e", "barking")
 
160
        opc, errc = runCommand(new(BootstrapCommand), "-e", "barking")
162
161
        c.Check((<-opc).Kind, Equals, dummy.OpNone)
163
162
        c.Check(<-errc, ErrorMatches, `broken environment`)
164
163
}
165
164
 
166
165
func (*cmdSuite) TestDestroyCommand(c *C) {
167
166
        // normal destroy
168
 
        opc, errc := runCommand(new(main.DestroyCommand))
 
167
        opc, errc := runCommand(new(DestroyCommand))
169
168
        c.Check(<-opc, Equals, op(dummy.OpDestroy, "peckham"))
170
169
        c.Check(<-errc, IsNil)
171
170
 
172
171
        // destroy with broken environment
173
 
        opc, errc = runCommand(new(main.DestroyCommand), "-e", "barking")
 
172
        opc, errc = runCommand(new(DestroyCommand), "-e", "barking")
174
173
        c.Check((<-opc).Kind, Equals, dummy.OpNone)
175
174
        c.Check(<-errc, ErrorMatches, `broken environment`)
176
175
}