func (*confSuite) TestValidateMissingExecStart(c *gc.C) { conf := common.Conf{ Desc: "some service", } err := conf.Validate(renderer) c.Check(err, gc.ErrorMatches, ".*missing ExecStart.*") }
func (*confSuite) TestValidateMissingDesc(c *gc.C) { conf := common.Conf{ ExecStart: "/path/to/some-command a b c", } err := conf.Validate(renderer) c.Check(err, gc.ErrorMatches, ".*missing Desc.*") }
func (*confSuite) TestValidateRelativeExecStart(c *gc.C) { conf := common.Conf{ Desc: "some service", ExecStart: "some-command a b c", } err := conf.Validate(renderer) c.Check(err, gc.ErrorMatches, `.*relative path in ExecStart \(.*`) }
func (*confSuite) TestValidatePartiallyQuotedExecutable(c *gc.C) { conf := common.Conf{ Desc: "some service", ExecStart: "'/path/to/some-command a b c'", } err := conf.Validate(renderer) c.Check(err, gc.ErrorMatches, `.*relative path in ExecStart \(.*`) }
func (*confSuite) TestValidateDoubleQuotedExecutable(c *gc.C) { conf := common.Conf{ Desc: "some service", ExecStart: `"/path/to/some-command" a b c`, } err := conf.Validate(renderer) c.Check(err, jc.ErrorIsNil) }
func (*confSuite) TestValidateOkay(c *gc.C) { conf := common.Conf{ Desc: "some service", ExecStart: "/path/to/some-command a b c", } err := conf.Validate(renderer) c.Check(err, jc.ErrorIsNil) }
func validate(name string, conf common.Conf, renderer shell.Renderer) error { if name == "" { return errors.NotValidf("missing service name") } if err := conf.Validate(renderer); err != nil { return errors.Trace(err) } if conf.ExtraScript != "" { return errors.NotValidf("unexpected ExtraScript") } // We ignore Desc and Logfile. for k := range conf.Limit { if _, ok := limitMap[k]; !ok { return errors.NotValidf("conf.Limit key %q", k) } } return nil }