github.com/mattyw/juju@v0.0.0-20140610034352-732aecd63861/cmd/juju/removerelation_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 charmtesting "github.com/juju/juju/charm/testing" 10 "github.com/juju/juju/cmd/envcmd" 11 jujutesting "github.com/juju/juju/juju/testing" 12 "github.com/juju/juju/testing" 13 ) 14 15 type RemoveRelationSuite struct { 16 jujutesting.RepoSuite 17 } 18 19 var _ = gc.Suite(&RemoveRelationSuite{}) 20 21 func runRemoveRelation(c *gc.C, args ...string) error { 22 _, err := testing.RunCommand(c, envcmd.Wrap(&RemoveRelationCommand{}), args...) 23 return err 24 } 25 26 func (s *RemoveRelationSuite) TestRemoveRelation(c *gc.C) { 27 charmtesting.Charms.BundlePath(s.SeriesPath, "riak") 28 err := runDeploy(c, "local:riak", "riak") 29 c.Assert(err, gc.IsNil) 30 charmtesting.Charms.BundlePath(s.SeriesPath, "logging") 31 err = runDeploy(c, "local:logging", "logging") 32 c.Assert(err, gc.IsNil) 33 runAddRelation(c, "riak", "logging") 34 35 // Destroy a relation that exists. 36 err = runRemoveRelation(c, "logging", "riak") 37 c.Assert(err, gc.IsNil) 38 39 // Destroy a relation that used to exist. 40 err = runRemoveRelation(c, "riak", "logging") 41 c.Assert(err, gc.ErrorMatches, `relation "logging:info riak:juju-info" not found`) 42 43 // Invalid removes. 44 err = runRemoveRelation(c, "ping", "pong") 45 c.Assert(err, gc.ErrorMatches, `service "ping" not found`) 46 err = runRemoveRelation(c, "riak") 47 c.Assert(err, gc.ErrorMatches, `a relation must involve two services`) 48 }