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