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

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

Issue 10166044: deploy refactoring
Left Patch Set: Created 10 years, 9 months ago
Right Patch Set: deploy refactoring Created 10 years, 9 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 | « cmd/juju/deploy.go ('k') | juju/conn.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 // Copyright 2012, 2013 Canonical Ltd. 1 // Copyright 2012, 2013 Canonical Ltd.
2 // Licensed under the AGPLv3, see LICENCE file for details. 2 // Licensed under the AGPLv3, see LICENCE file for details.
3 3
4 package main 4 package main
5 5
6 import ( 6 import (
7 . "launchpad.net/gocheck" 7 . "launchpad.net/gocheck"
8 "launchpad.net/juju-core/charm" 8 "launchpad.net/juju-core/charm"
9 "launchpad.net/juju-core/constraints" 9 "launchpad.net/juju-core/constraints"
10 "launchpad.net/juju-core/errors" 10 "launchpad.net/juju-core/errors"
(...skipping 21 matching lines...) Expand all
32 args: nil, 32 args: nil,
33 err: `no charm specified`, 33 err: `no charm specified`,
34 }, { 34 }, {
35 args: []string{"craz~ness"}, 35 args: []string{"craz~ness"},
36 err: `invalid charm name "craz~ness"`, 36 err: `invalid charm name "craz~ness"`,
37 }, { 37 }, {
38 args: []string{"craziness", "burble-1"}, 38 args: []string{"craziness", "burble-1"},
39 err: `invalid service name "burble-1"`, 39 err: `invalid service name "burble-1"`,
40 }, { 40 }, {
41 args: []string{"craziness", "burble1", "-n", "0"}, 41 args: []string{"craziness", "burble1", "-n", "0"},
42 » » err: `must deploy at least one unit`, 42 » » err: `--num-units must be a positive integer`,
43 }, { 43 }, {
44 args: []string{"craziness", "burble1", "--force-machine", "biggl esplop"}, 44 args: []string{"craziness", "burble1", "--force-machine", "biggl esplop"},
45 err: `invalid machine id "bigglesplop"`, 45 err: `invalid machine id "bigglesplop"`,
46 }, { 46 }, {
47 args: []string{"craziness", "burble1", "-n", "2", "--force-machi ne", "123"}, 47 args: []string{"craziness", "burble1", "-n", "2", "--force-machi ne", "123"},
48 err: `cannot use --num-units with --force-machine`, 48 err: `cannot use --num-units with --force-machine`,
49 }, { 49 }, {
50 args: []string{"craziness", "burble1", "--constraints", "gibber= plop"}, 50 args: []string{"craziness", "burble1", "--constraints", "gibber= plop"},
51 err: `invalid value "gibber=plop" for flag --constraints: unkno wn constraint "gibber"`, 51 err: `invalid value "gibber=plop" for flag --constraints: unkno wn constraint "gibber"`,
52 }, 52 },
53 } 53 }
54 54
55 func (s *DeploySuite) TestInitErrors(c *C) { 55 func (s *DeploySuite) TestInitErrors(c *C) {
56 for i, t := range initErrorTests { 56 for i, t := range initErrorTests {
57 c.Logf("test %d", i) 57 c.Logf("test %d", i)
58 err := coretesting.InitCommand(&DeployCommand{}, t.args) 58 err := coretesting.InitCommand(&DeployCommand{}, t.args)
59 c.Assert(err, ErrorMatches, t.err) 59 c.Assert(err, ErrorMatches, t.err)
60 } 60 }
61 } 61 }
62 62
rog 2013/06/11 13:22:07 tyvm for the extra tests.
63 func (s *DeploySuite) TestNoCharm(c *C) { 63 func (s *DeploySuite) TestNoCharm(c *C) {
64 err := runDeploy(c, "local:unknown-123") 64 err := runDeploy(c, "local:unknown-123")
65 c.Assert(err, ErrorMatches, `cannot get charm: charm not found in ".*": local:precise/unknown-123`) 65 c.Assert(err, ErrorMatches, `cannot get charm: charm not found in ".*": local:precise/unknown-123`)
66 } 66 }
67 67
68 func (s *DeploySuite) TestCharmDir(c *C) { 68 func (s *DeploySuite) TestCharmDir(c *C) {
69 coretesting.Charms.ClonedDirPath(s.SeriesPath, "dummy") 69 coretesting.Charms.ClonedDirPath(s.SeriesPath, "dummy")
70 err := runDeploy(c, "local:dummy") 70 err := runDeploy(c, "local:dummy")
71 c.Assert(err, IsNil) 71 c.Assert(err, IsNil)
72 curl := charm.MustParseURL("local:precise/dummy-1") 72 curl := charm.MustParseURL("local:precise/dummy-1")
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 curl := charm.MustParseURL("local:precise/dummy-1") 144 curl := charm.MustParseURL("local:precise/dummy-1")
145 service, _ := s.AssertService(c, "dummy", curl, 1, 0) 145 service, _ := s.AssertService(c, "dummy", curl, 1, 0)
146 cons, err := service.Constraints() 146 cons, err := service.Constraints()
147 c.Assert(err, IsNil) 147 c.Assert(err, IsNil)
148 c.Assert(cons, DeepEquals, constraints.MustParse("mem=2G cpu-cores=2")) 148 c.Assert(cons, DeepEquals, constraints.MustParse("mem=2G cpu-cores=2"))
149 } 149 }
150 150
151 func (s *DeploySuite) TestSubordinateConstraints(c *C) { 151 func (s *DeploySuite) TestSubordinateConstraints(c *C) {
152 coretesting.Charms.BundlePath(s.SeriesPath, "logging") 152 coretesting.Charms.BundlePath(s.SeriesPath, "logging")
153 err := runDeploy(c, "local:logging", "--constraints", "mem=1G") 153 err := runDeploy(c, "local:logging", "--constraints", "mem=1G")
154 » c.Assert(err, ErrorMatches, "cannot specify constraints for subordinate service") 154 » c.Assert(err, ErrorMatches, "cannot use --constraints with subordinate s ervice")
155 } 155 }
156 156
157 func (s *DeploySuite) TestNumUnits(c *C) { 157 func (s *DeploySuite) TestNumUnits(c *C) {
158 coretesting.Charms.BundlePath(s.SeriesPath, "dummy") 158 coretesting.Charms.BundlePath(s.SeriesPath, "dummy")
159 err := runDeploy(c, "local:dummy", "-n", "13") 159 err := runDeploy(c, "local:dummy", "-n", "13")
160 c.Assert(err, IsNil) 160 c.Assert(err, IsNil)
161 curl := charm.MustParseURL("local:precise/dummy-1") 161 curl := charm.MustParseURL("local:precise/dummy-1")
162 s.AssertService(c, "dummy", curl, 13, 0) 162 s.AssertService(c, "dummy", curl, 13, 0)
163 } 163 }
164 164
165 func (s *DeploySuite) TestNumUnitsSubordinate(c *C) { 165 func (s *DeploySuite) TestNumUnitsSubordinate(c *C) {
166 coretesting.Charms.BundlePath(s.SeriesPath, "logging") 166 coretesting.Charms.BundlePath(s.SeriesPath, "logging")
167 err := runDeploy(c, "--num-units", "3", "local:logging") 167 err := runDeploy(c, "--num-units", "3", "local:logging")
168 » c.Assert(err, ErrorMatches, `cannot specify units for subordinate servic e`) 168 » c.Assert(err, ErrorMatches, "cannot use --num-units or --force-machine w ith subordinate service")
169 _, err = s.State.Service("dummy") 169 _, err = s.State.Service("dummy")
170 c.Assert(err, ErrorMatches, `service "dummy" not found`) 170 c.Assert(err, ErrorMatches, `service "dummy" not found`)
171 } 171 }
172 172
173 func (s *DeploySuite) TestForceMachine(c *C) { 173 func (s *DeploySuite) TestForceMachine(c *C) {
174 coretesting.Charms.BundlePath(s.SeriesPath, "dummy") 174 coretesting.Charms.BundlePath(s.SeriesPath, "dummy")
175 machine, err := s.State.AddMachine("precise", state.JobHostUnits) 175 machine, err := s.State.AddMachine("precise", state.JobHostUnits)
176 c.Assert(err, IsNil) 176 c.Assert(err, IsNil)
177 err = runDeploy(c, "--force-machine", machine.Id(), "local:dummy", "port landia") 177 err = runDeploy(c, "--force-machine", machine.Id(), "local:dummy", "port landia")
178 c.Assert(err, IsNil) 178 c.Assert(err, IsNil)
(...skipping 13 matching lines...) Expand all
192 c.Assert(err, ErrorMatches, `cannot assign unit "portlandia/0" to machin e: machine 42 not found`) 192 c.Assert(err, ErrorMatches, `cannot assign unit "portlandia/0" to machin e: machine 42 not found`)
193 _, err = s.State.Service("dummy") 193 _, err = s.State.Service("dummy")
194 c.Assert(err, ErrorMatches, `service "dummy" not found`) 194 c.Assert(err, ErrorMatches, `service "dummy" not found`)
195 } 195 }
196 196
197 func (s *DeploySuite) TestForceMachineSubordinate(c *C) { 197 func (s *DeploySuite) TestForceMachineSubordinate(c *C) {
198 machine, err := s.State.AddMachine("precise", state.JobHostUnits) 198 machine, err := s.State.AddMachine("precise", state.JobHostUnits)
199 c.Assert(err, IsNil) 199 c.Assert(err, IsNil)
200 coretesting.Charms.BundlePath(s.SeriesPath, "logging") 200 coretesting.Charms.BundlePath(s.SeriesPath, "logging")
201 err = runDeploy(c, "--force-machine", machine.Id(), "local:logging") 201 err = runDeploy(c, "--force-machine", machine.Id(), "local:logging")
202 » c.Assert(err, ErrorMatches, `cannot specify units for subordinate servic e`) 202 » c.Assert(err, ErrorMatches, "cannot use --num-units or --force-machine w ith subordinate service")
203 » _, err = s.State.Service("dummy") 203 » _, err = s.State.Service("dummy")
204 » c.Assert(err, ErrorMatches, `service "dummy" not found`) 204 » c.Assert(err, ErrorMatches, `service "dummy" not found`)
205 } 205 }
LEFTRIGHT

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