1
// Copyright 2015 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
7
jc "github.com/juju/testing/checkers"
10
"github.com/juju/juju/cmd/juju/service"
11
"github.com/juju/juju/testing"
14
type ServiceConstraintsCommandsSuite struct {
15
testing.FakeJujuHomeSuite
18
var _ = gc.Suite(&ServiceConstraintsCommandsSuite{})
20
func (s *ServiceConstraintsCommandsSuite) TestSetInit(c *gc.C) {
21
for _, test := range []struct {
26
args: []string{"--service", "mysql", "mem=4G"},
27
err: `flag provided but not defined: --service`,
29
args: []string{"-s", "mysql", "mem=4G"},
30
err: `flag provided but not defined: -s`,
33
err: `no service name specified`,
35
args: []string{"mysql", "="},
36
err: `malformed constraint "="`,
38
args: []string{"cpu-power=250"},
39
err: `invalid service name "cpu-power=250"`,
41
args: []string{"mysql", "cpu-power=250"},
44
err := testing.InitCommand(&service.ServiceSetConstraintsCommand{}, test.args)
46
c.Check(err, jc.ErrorIsNil)
48
c.Check(err, gc.ErrorMatches, test.err)
53
func (s *ServiceConstraintsCommandsSuite) TestGetInit(c *gc.C) {
54
for _, test := range []struct {
59
args: []string{"-s", "mysql"},
60
err: `flag provided but not defined: -s`,
62
args: []string{"--service", "mysql"},
63
err: `flag provided but not defined: --service`,
66
err: `no service name specified`,
68
args: []string{"mysql-0"},
69
err: `invalid service name "mysql-0"`,
71
args: []string{"mysql"},
74
err := testing.InitCommand(&service.ServiceGetConstraintsCommand{}, test.args)
76
c.Check(err, jc.ErrorIsNil)
78
c.Check(err, gc.ErrorMatches, test.err)