github.com/mattyw/juju@v0.0.0-20140610034352-732aecd63861/cmd/juju/removeunit_test.go (about) 1 // Copyright 2012, 2013 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package main 5 6 import ( 7 gc "launchpad.net/gocheck" 8 9 "github.com/juju/juju/charm" 10 charmtesting "github.com/juju/juju/charm/testing" 11 "github.com/juju/juju/cmd/envcmd" 12 jujutesting "github.com/juju/juju/juju/testing" 13 "github.com/juju/juju/state" 14 "github.com/juju/juju/testing" 15 ) 16 17 type RemoveUnitSuite struct { 18 jujutesting.RepoSuite 19 } 20 21 var _ = gc.Suite(&RemoveUnitSuite{}) 22 23 func runRemoveUnit(c *gc.C, args ...string) error { 24 _, err := testing.RunCommand(c, envcmd.Wrap(&RemoveUnitCommand{}), args...) 25 return err 26 } 27 28 func (s *RemoveUnitSuite) TestRemoveUnit(c *gc.C) { 29 charmtesting.Charms.BundlePath(s.SeriesPath, "dummy") 30 err := runDeploy(c, "-n", "2", "local:dummy", "dummy") 31 c.Assert(err, gc.IsNil) 32 curl := charm.MustParseURL("local:precise/dummy-1") 33 svc, _ := s.AssertService(c, "dummy", curl, 2, 0) 34 35 err = runRemoveUnit(c, "dummy/0", "dummy/1", "dummy/2", "sillybilly/17") 36 c.Assert(err, gc.ErrorMatches, `some units were not destroyed: unit "dummy/2" does not exist; unit "sillybilly/17" does not exist`) 37 units, err := svc.AllUnits() 38 c.Assert(err, gc.IsNil) 39 for _, u := range units { 40 c.Assert(u.Life(), gc.Equals, state.Dying) 41 } 42 }