github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/featuretests/cmd_juju_relation_test.go (about)

     1  // Copyright 2016 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package featuretests
     5  
     6  import (
     7  	"os"
     8  
     9  	gc "gopkg.in/check.v1"
    10  
    11  	"github.com/juju/juju/juju/osenv"
    12  	jujutesting "github.com/juju/juju/juju/testing"
    13  )
    14  
    15  type CmdRelationSuite struct {
    16  	jujutesting.JujuConnSuite
    17  	apps []string
    18  }
    19  
    20  func (s *CmdRelationSuite) SetUpTest(c *gc.C) {
    21  	s.JujuConnSuite.SetUpTest(c)
    22  	os.Setenv(osenv.JujuModelEnvKey, "")
    23  
    24  	s.apps = []string{"wordpress", "mysql"}
    25  	for _, app := range s.apps {
    26  		ch := s.AddTestingCharm(c, app)
    27  		s.AddTestingService(c, app, ch)
    28  	}
    29  }
    30  
    31  func (s *CmdRelationSuite) TestAddRelationSuccess(c *gc.C) {
    32  	runCommandExpectSuccess(c, "add-relation", s.apps...)
    33  }
    34  
    35  func (s *CmdRelationSuite) TestAddRelationFail(c *gc.C) {
    36  	runCommandExpectSuccess(c, "add-relation", s.apps...)
    37  	runCommandExpectFailure(c, "add-relation", `cannot add relation "wordpress:db mysql:server": relation already exists`, s.apps...)
    38  }
    39  
    40  func (s *CmdRelationSuite) TestRemoveRelationSuccess(c *gc.C) {
    41  	runCommandExpectSuccess(c, "add-relation", s.apps...)
    42  	runCommandExpectSuccess(c, "remove-relation", s.apps...)
    43  }
    44  
    45  func (s *CmdRelationSuite) TestRemoveRelationFail(c *gc.C) {
    46  	runCommandExpectFailure(c, "remove-relation", `relation "wordpress:db mysql:server" not found`, s.apps...)
    47  }