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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
// Copyright 2015 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package service_test
import (
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
"github.com/juju/juju/cmd/juju/service"
"github.com/juju/juju/testing"
)
type ServiceConstraintsCommandsSuite struct {
testing.FakeJujuHomeSuite
}
var _ = gc.Suite(&ServiceConstraintsCommandsSuite{})
func (s *ServiceConstraintsCommandsSuite) TestSetInit(c *gc.C) {
for _, test := range []struct {
args []string
err string
}{
{
args: []string{"--service", "mysql", "mem=4G"},
err: `flag provided but not defined: --service`,
}, {
args: []string{"-s", "mysql", "mem=4G"},
err: `flag provided but not defined: -s`,
}, {
args: []string{},
err: `no service name specified`,
}, {
args: []string{"mysql", "="},
err: `malformed constraint "="`,
}, {
args: []string{"cpu-power=250"},
err: `invalid service name "cpu-power=250"`,
}, {
args: []string{"mysql", "cpu-power=250"},
},
} {
err := testing.InitCommand(&service.ServiceSetConstraintsCommand{}, test.args)
if test.err == "" {
c.Check(err, jc.ErrorIsNil)
} else {
c.Check(err, gc.ErrorMatches, test.err)
}
}
}
func (s *ServiceConstraintsCommandsSuite) TestGetInit(c *gc.C) {
for _, test := range []struct {
args []string
err string
}{
{
args: []string{"-s", "mysql"},
err: `flag provided but not defined: -s`,
}, {
args: []string{"--service", "mysql"},
err: `flag provided but not defined: --service`,
}, {
args: []string{},
err: `no service name specified`,
}, {
args: []string{"mysql-0"},
err: `invalid service name "mysql-0"`,
}, {
args: []string{"mysql"},
},
} {
err := testing.InitCommand(&service.ServiceGetConstraintsCommand{}, test.args)
if test.err == "" {
c.Check(err, jc.ErrorIsNil)
} else {
c.Check(err, gc.ErrorMatches, test.err)
}
}
}
|