Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(6)

Delta Between Two Patch Sets: cmd/juju/cmd_test.go

Issue 6304104: environs/dummy: enhance start/stop operations (Closed)
Left Patch Set: environs/dummy: enhance start/stop operations Created 12 years, 9 months ago
Right Patch Set: environs/dummy: enhance start/stop operations Created 12 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « [revision details] ('k') | cmd/jujud/provisioning_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 package main 1 package main
2 2
3 import ( 3 import (
4 "io/ioutil" 4 "io/ioutil"
5 "launchpad.net/gnuflag" 5 "launchpad.net/gnuflag"
6 . "launchpad.net/gocheck" 6 . "launchpad.net/gocheck"
7 » "launchpad.net/juju-core/juju/cmd" 7 » "launchpad.net/juju-core/cmd"
8 » "launchpad.net/juju-core/juju/environs" 8 » "launchpad.net/juju-core/environs"
9 » "launchpad.net/juju-core/juju/environs/dummy" 9 » "launchpad.net/juju-core/environs/dummy"
10 » "launchpad.net/juju-core/juju/testing" 10 » "launchpad.net/juju-core/testing"
11 "os" 11 "os"
12 "path/filepath" 12 "path/filepath"
13 "reflect" 13 "reflect"
14 ) 14 )
15 15
16 type cmdSuite struct { 16 type cmdSuite struct {
17 testing.LoggingSuite 17 testing.LoggingSuite
18 home string 18 home string
19 } 19 }
20 20
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 errc <- err 130 errc <- err
131 return 131 return
132 } 132 }
133 133
134 err = com.Run(cmd.DefaultContext()) 134 err = com.Run(cmd.DefaultContext())
135 errc <- err 135 errc <- err
136 }() 136 }()
137 return 137 return
138 } 138 }
139 139
140 func checkOp(c *C, op dummy.Operation, kind dummy.OperationKind, env string) {
141 c.Check(op.Kind(), Equals, kind)
142 c.Check(op.Env(), Equals, env)
143 }
144
145 func (*cmdSuite) TestBootstrapCommand(c *C) { 140 func (*cmdSuite) TestBootstrapCommand(c *C) {
146 // normal bootstrap 141 // normal bootstrap
147 opc, errc := runCommand(new(BootstrapCommand)) 142 opc, errc := runCommand(new(BootstrapCommand))
148 » checkOp(c, <-opc, dummy.OpBootstrap, "peckham") 143 » c.Check((<-opc).(dummy.OpBootstrap).Env, Equals, "peckham")
149 c.Check(<-errc, IsNil) 144 c.Check(<-errc, IsNil)
150 145
151 // bootstrap with tool uploading - checking that a file 146 // bootstrap with tool uploading - checking that a file
152 // is uploaded should be sufficient, as the detailed semantics 147 // is uploaded should be sufficient, as the detailed semantics
153 // of UploadTools are tested in environs. 148 // of UploadTools are tested in environs.
154 opc, errc = runCommand(new(BootstrapCommand), "--upload-tools") 149 opc, errc = runCommand(new(BootstrapCommand), "--upload-tools")
155 » checkOp(c, <-opc, dummy.OpPutFile, "peckham") 150 » c.Check((<-opc).(dummy.OpPutFile).Env, Equals, "peckham")
156 » checkOp(c, <-opc, dummy.OpBootstrap, "peckham") 151 » c.Check((<-opc).(dummy.OpBootstrap).Env, Equals, "peckham")
157 c.Check(<-errc, IsNil) 152 c.Check(<-errc, IsNil)
158 153
159 envs, err := environs.ReadEnvirons("") 154 envs, err := environs.ReadEnvirons("")
160 c.Assert(err, IsNil) 155 c.Assert(err, IsNil)
161 env, err := envs.Open("peckham") 156 env, err := envs.Open("peckham")
162 c.Assert(err, IsNil) 157 c.Assert(err, IsNil)
163 dir := c.MkDir() 158 dir := c.MkDir()
164 err = environs.GetTools(env, dir) 159 err = environs.GetTools(env, dir)
165 c.Assert(err, IsNil) 160 c.Assert(err, IsNil)
166 161
167 // bootstrap with broken environment 162 // bootstrap with broken environment
168 opc, errc = runCommand(new(BootstrapCommand), "-e", "barking") 163 opc, errc = runCommand(new(BootstrapCommand), "-e", "barking")
169 c.Check(<-opc, IsNil) 164 c.Check(<-opc, IsNil)
170 c.Check(<-errc, ErrorMatches, `broken environment`) 165 c.Check(<-errc, ErrorMatches, `broken environment`)
171 } 166 }
172 167
173 func (*cmdSuite) TestDestroyCommand(c *C) { 168 func (*cmdSuite) TestDestroyCommand(c *C) {
174 // normal destroy 169 // normal destroy
175 opc, errc := runCommand(new(DestroyCommand)) 170 opc, errc := runCommand(new(DestroyCommand))
176 » checkOp(c, <-opc, dummy.OpDestroy, "peckham") 171 » c.Check((<-opc).(dummy.OpDestroy).Env, Equals, "peckham")
177 c.Check(<-errc, IsNil) 172 c.Check(<-errc, IsNil)
178 173
179 // destroy with broken environment 174 // destroy with broken environment
180 opc, errc = runCommand(new(DestroyCommand), "-e", "barking") 175 opc, errc = runCommand(new(DestroyCommand), "-e", "barking")
181 c.Check(<-opc, IsNil) 176 c.Check(<-opc, IsNil)
182 c.Check(<-errc, ErrorMatches, `broken environment`) 177 c.Check(<-errc, ErrorMatches, `broken environment`)
183 } 178 }
184 179
185 var deployTests = []struct { 180 var deployTests = []struct {
186 args []string 181 args []string
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 // missing args 239 // missing args
245 _, err := initDeployCommand() 240 _, err := initDeployCommand()
246 c.Assert(err, ErrorMatches, "no charm specified") 241 c.Assert(err, ErrorMatches, "no charm specified")
247 242
248 // bad unit count 243 // bad unit count
249 _, err = initDeployCommand("charm-name", "--num-units", "0") 244 _, err = initDeployCommand("charm-name", "--num-units", "0")
250 c.Assert(err, ErrorMatches, "must deploy at least one unit") 245 c.Assert(err, ErrorMatches, "must deploy at least one unit")
251 246
252 // environment tested elsewhere 247 // environment tested elsewhere
253 } 248 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b