コード例 #1
0
ファイル: conf_test.go プロジェクト: howbazaar/juju
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
ファイル: conf_test.go プロジェクト: howbazaar/juju
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
ファイル: conf_test.go プロジェクト: howbazaar/juju
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
ファイル: conf_test.go プロジェクト: howbazaar/juju
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
ファイル: conf_test.go プロジェクト: howbazaar/juju
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
ファイル: conf_test.go プロジェクト: howbazaar/juju
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
ファイル: conf.go プロジェクト: Pankov404/juju
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
}