Пример #1
0
func (*confSuite) TestValidateMissingExecStart(c *gc.C) {
	conf := common.Conf{
		Desc: "some service",
	}
	err := conf.Validate(renderer)

	c.Check(err, gc.ErrorMatches, ".*missing ExecStart.*")
}
Пример #2
0
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.*")
}
Пример #3
0
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 \(.*`)
}
Пример #4
0
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 \(.*`)
}
Пример #5
0
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)
}
Пример #6
0
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)
}
Пример #7
0
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
}