1
// Copyright 2015 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
7
"github.com/juju/testing"
8
jc "github.com/juju/testing/checkers"
9
"github.com/juju/utils/shell"
10
gc "gopkg.in/check.v1"
12
"github.com/juju/juju/service/common"
15
var renderer = &shell.BashRenderer{}
17
type confSuite struct {
18
testing.IsolationSuite
21
var _ = gc.Suite(&confSuite{})
23
func (*confSuite) TestIsZeroTrue(c *gc.C) {
25
isZero := conf.IsZero()
27
c.Check(isZero, jc.IsTrue)
30
func (*confSuite) TestIsZero(c *gc.C) {
33
ExecStart: "/path/to/some-command a b c",
35
isZero := conf.IsZero()
37
c.Check(isZero, jc.IsFalse)
40
func (*confSuite) TestValidateOkay(c *gc.C) {
43
ExecStart: "/path/to/some-command a b c",
45
err := conf.Validate(renderer)
47
c.Check(err, jc.ErrorIsNil)
50
func (*confSuite) TestValidateSingleQuotedExecutable(c *gc.C) {
53
ExecStart: "'/path/to/some-command' a b c",
55
err := conf.Validate(renderer)
57
c.Check(err, jc.ErrorIsNil)
60
func (*confSuite) TestValidateDoubleQuotedExecutable(c *gc.C) {
63
ExecStart: `"/path/to/some-command" a b c`,
65
err := conf.Validate(renderer)
67
c.Check(err, jc.ErrorIsNil)
70
func (*confSuite) TestValidatePartiallyQuotedExecutable(c *gc.C) {
73
ExecStart: "'/path/to/some-command a b c'",
75
err := conf.Validate(renderer)
77
c.Check(err, gc.ErrorMatches, `.*relative path in ExecStart \(.*`)
80
func (*confSuite) TestValidateMissingDesc(c *gc.C) {
82
ExecStart: "/path/to/some-command a b c",
84
err := conf.Validate(renderer)
86
c.Check(err, gc.ErrorMatches, ".*missing Desc.*")
89
func (*confSuite) TestValidateMissingExecStart(c *gc.C) {
93
err := conf.Validate(renderer)
95
c.Check(err, gc.ErrorMatches, ".*missing ExecStart.*")
98
func (*confSuite) TestValidateRelativeExecStart(c *gc.C) {
100
Desc: "some service",
101
ExecStart: "some-command a b c",
103
err := conf.Validate(renderer)
105
c.Check(err, gc.ErrorMatches, `.*relative path in ExecStart \(.*`)
108
func (*confSuite) TestValidateRelativeExecStopPost(c *gc.C) {
110
Desc: "some service",
111
ExecStart: "/path/to/some-command a b c",
112
ExecStopPost: "some-other-command a b c",
114
err := conf.Validate(renderer)
116
c.Check(err, gc.ErrorMatches, `.*relative path in ExecStopPost \(.*`)