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

Side by Side Diff: state/statecmd/deploy_test.go

Issue 10083047: state: Service ConfigSettings methods
Patch Set: state: Service ConfigSettings methods 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:
View unified diff | Download patch
« no previous file with comments | « state/statecmd/config_test.go ('k') | state/statecmd/get.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 package statecmd_test 1 package statecmd_test
2 2
3 import ( 3 import (
4 . "launchpad.net/gocheck" 4 . "launchpad.net/gocheck"
5 "launchpad.net/juju-core/charm" 5 "launchpad.net/juju-core/charm"
6 "launchpad.net/juju-core/constraints" 6 "launchpad.net/juju-core/constraints"
7 "launchpad.net/juju-core/juju/testing" 7 "launchpad.net/juju-core/juju/testing"
8 "launchpad.net/juju-core/state" 8 "launchpad.net/juju-core/state"
9 "launchpad.net/juju-core/state/api/params" 9 "launchpad.net/juju-core/state/api/params"
10 "launchpad.net/juju-core/state/statecmd" 10 "launchpad.net/juju-core/state/statecmd"
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 "username": "", 212 "username": "",
213 }, 213 },
214 NumUnits: 1, 214 NumUnits: 1,
215 } 215 }
216 err := s.runDeploy(c, args) 216 err := s.runDeploy(c, args)
217 c.Assert(err, IsNil) 217 c.Assert(err, IsNil)
218 curl := charm.MustParseURL("local:precise/dummy-1") 218 curl := charm.MustParseURL("local:precise/dummy-1")
219 s.AssertService(c, "dummy", curl, 1, 0) 219 s.AssertService(c, "dummy", curl, 1, 0)
220 svc, err := s.State.Service("dummy") 220 svc, err := s.State.Service("dummy")
221 c.Assert(err, IsNil) 221 c.Assert(err, IsNil)
222 » cfg, err := svc.Config() 222 » settings, err := svc.ConfigSettings()
223 c.Assert(err, IsNil) 223 c.Assert(err, IsNil)
224 » c.Assert(cfg.Map(), DeepEquals, map[string]interface{}{ 224 » c.Assert(settings, DeepEquals, charm.Settings{
225 "skill-level": int64(1), 225 "skill-level": int64(1),
226 }) 226 })
227 } 227 }
228 228
229 func (s *DeploySuite) TestConfigYAML(c *C) { 229 func (s *DeploySuite) TestConfigYAML(c *C) {
230 coretesting.Charms.BundlePath(s.SeriesPath, "dummy") 230 coretesting.Charms.BundlePath(s.SeriesPath, "dummy")
231 args := params.ServiceDeploy{ 231 args := params.ServiceDeploy{
232 CharmUrl: "local:dummy", 232 CharmUrl: "local:dummy",
233 ConfigYAML: "dummy: {skill-level: 9001, username: null}", 233 ConfigYAML: "dummy: {skill-level: 9001, username: null}",
234 NumUnits: 1, 234 NumUnits: 1,
235 } 235 }
236 err := s.runDeploy(c, args) 236 err := s.runDeploy(c, args)
237 c.Assert(err, IsNil) 237 c.Assert(err, IsNil)
238 curl := charm.MustParseURL("local:precise/dummy-1") 238 curl := charm.MustParseURL("local:precise/dummy-1")
239 s.AssertService(c, "dummy", curl, 1, 0) 239 s.AssertService(c, "dummy", curl, 1, 0)
240 svc, err := s.State.Service("dummy") 240 svc, err := s.State.Service("dummy")
241 c.Assert(err, IsNil) 241 c.Assert(err, IsNil)
242 » cfg, err := svc.Config() 242 » settings, err := svc.ConfigSettings()
243 c.Assert(err, IsNil) 243 c.Assert(err, IsNil)
244 » c.Assert(cfg.Map(), DeepEquals, map[string]interface{}{ 244 » c.Assert(settings, DeepEquals, charm.Settings{
245 "skill-level": int64(9001), 245 "skill-level": int64(9001),
246 }) 246 })
247 } 247 }
248 248
249 func (s *DeploySuite) TestConstraints(c *C) { 249 func (s *DeploySuite) TestConstraints(c *C) {
250 coretesting.Charms.BundlePath(s.SeriesPath, "dummy") 250 coretesting.Charms.BundlePath(s.SeriesPath, "dummy")
251 args := params.ServiceDeploy{ 251 args := params.ServiceDeploy{
252 CharmUrl: "local:dummy", 252 CharmUrl: "local:dummy",
253 Constraints: constraints.MustParse("mem=2G cpu-cores=2"), 253 Constraints: constraints.MustParse("mem=2G cpu-cores=2"),
254 NumUnits: 1, 254 NumUnits: 1,
255 } 255 }
256 err := s.runDeploy(c, args) 256 err := s.runDeploy(c, args)
257 c.Assert(err, IsNil) 257 c.Assert(err, IsNil)
258 curl := charm.MustParseURL("local:precise/dummy-1") 258 curl := charm.MustParseURL("local:precise/dummy-1")
259 service, _ := s.AssertService(c, "dummy", curl, 1, 0) 259 service, _ := s.AssertService(c, "dummy", curl, 1, 0)
260 cons, err := service.Constraints() 260 cons, err := service.Constraints()
261 c.Assert(err, IsNil) 261 c.Assert(err, IsNil)
262 c.Assert(cons, DeepEquals, constraints.MustParse("mem=2G cpu-cores=2")) 262 c.Assert(cons, DeepEquals, constraints.MustParse("mem=2G cpu-cores=2"))
263 } 263 }
264 264
265 func (s *DeploySuite) TestSubordinateConstraints(c *C) { 265 func (s *DeploySuite) TestSubordinateConstraints(c *C) {
266 coretesting.Charms.BundlePath(s.SeriesPath, "logging") 266 coretesting.Charms.BundlePath(s.SeriesPath, "logging")
267 args := params.ServiceDeploy{ 267 args := params.ServiceDeploy{
268 CharmUrl: "local:logging", 268 CharmUrl: "local:logging",
269 Constraints: constraints.MustParse("mem=1G"), 269 Constraints: constraints.MustParse("mem=1G"),
270 } 270 }
271 err := s.runDeploy(c, args) 271 err := s.runDeploy(c, args)
272 c.Assert(err, Equals, state.ErrSubordinateConstraints) 272 c.Assert(err, Equals, state.ErrSubordinateConstraints)
273 } 273 }
OLDNEW
« no previous file with comments | « state/statecmd/config_test.go ('k') | state/statecmd/get.go » ('j') | no next file with comments »

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