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

Unified Diff: state/apiserver/client/client_test.go

Issue 76910044: state/api: Add Client.ServiceDeployWithNetworks (Closed)
Patch Set: state/api: Add Client.ServiceDeployWithNetworks Created 11 years ago
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « state/apiserver/client/client.go ('k') | state/apiserver/client/perm_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: state/apiserver/client/client_test.go
=== modified file 'state/apiserver/client/client_test.go'
--- state/apiserver/client/client_test.go 2014-03-26 07:01:48 +0000
+++ state/apiserver/client/client_test.go 2014-03-26 09:49:29 +0000
@@ -680,6 +680,50 @@
}
}
+func (s *clientSuite) TestClientServiceDeployWithNetworks(c *gc.C) {
+ store, restore := makeMockCharmStore()
+ defer restore()
+ curl, bundle := addCharm(c, store, "dummy")
+ mem4g := constraints.MustParse("mem=4G")
+ err := s.APIState.Client().ServiceDeployWithNetworks(
+ curl.String(), "service", 3, "", mem4g, "", []string{"net1", "net2"}, []string{"net3"},
+ )
+ c.Assert(err, gc.IsNil)
+ service := s.assertPrincipalDeployed(c, "service", curl, false, bundle, mem4g)
+
+ include, exclude, err := service.Networks()
+ c.Assert(err, gc.IsNil)
+ c.Assert(include, gc.DeepEquals, []string{"net1", "net2"})
+ c.Assert(exclude, gc.DeepEquals, []string{"net3"})
+}
+
+func (s *clientSuite) assertPrincipalDeployed(c *gc.C, serviceName string, curl *charm.URL, forced bool, bundle charm.Charm, cons constraints.Value) *state.Service {
+ service, err := s.State.Service(serviceName)
+ c.Assert(err, gc.IsNil)
+ charm, force, err := service.Charm()
+ c.Assert(err, gc.IsNil)
+ c.Assert(force, gc.Equals, forced)
+ c.Assert(charm.URL(), gc.DeepEquals, curl)
+ c.Assert(charm.Meta(), gc.DeepEquals, bundle.Meta())
+ c.Assert(charm.Config(), gc.DeepEquals, bundle.Config())
+
+ serviceCons, err := service.Constraints()
+ c.Assert(err, gc.IsNil)
+ c.Assert(serviceCons, gc.DeepEquals, cons)
+ units, err := service.AllUnits()
+ c.Assert(err, gc.IsNil)
+ for _, unit := range units {
+ mid, err := unit.AssignedMachineId()
+ c.Assert(err, gc.IsNil)
+ machine, err := s.State.Machine(mid)
+ c.Assert(err, gc.IsNil)
+ machineCons, err := machine.Constraints()
+ c.Assert(err, gc.IsNil)
+ c.Assert(machineCons, gc.DeepEquals, cons)
+ }
+ return service
+}
+
func (s *clientSuite) TestClientServiceDeployPrincipal(c *gc.C) {
// TODO(fwereade): test ToMachineSpec directly on srvClient, when we
// manage to extract it as a package and can thus do it conveniently.
@@ -691,29 +735,7 @@
curl.String(), "service", 3, "", mem4g, "",
)
c.Assert(err, gc.IsNil)
- service, err := s.State.Service("service")
- c.Assert(err, gc.IsNil)
- charm, force, err := service.Charm()
- c.Assert(err, gc.IsNil)
- c.Assert(force, gc.Equals, false)
- c.Assert(charm.URL(), gc.DeepEquals, curl)
- c.Assert(charm.Meta(), gc.DeepEquals, bundle.Meta())
- c.Assert(charm.Config(), gc.DeepEquals, bundle.Config())
-
- cons, err := service.Constraints()
- c.Assert(err, gc.IsNil)
- c.Assert(cons, gc.DeepEquals, mem4g)
- units, err := service.AllUnits()
- c.Assert(err, gc.IsNil)
- for _, unit := range units {
- mid, err := unit.AssignedMachineId()
- c.Assert(err, gc.IsNil)
- machine, err := s.State.Machine(mid)
- c.Assert(err, gc.IsNil)
- cons, err := machine.Constraints()
- c.Assert(err, gc.IsNil)
- c.Assert(cons, gc.DeepEquals, mem4g)
- }
+ s.assertPrincipalDeployed(c, "service", curl, false, bundle, mem4g)
}
func (s *clientSuite) TestClientServiceDeploySubordinate(c *gc.C) {
« no previous file with comments | « state/apiserver/client/client.go ('k') | state/apiserver/client/perm_test.go » ('j') | no next file with comments »

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