示例#1
0
文件: upstart_test.go 项目: bac/juju
func (s *IsRunningSuite) TestInitctlCantBeRun(c *gc.C) {
	s.createInitctl(c, "", 0, modeNotExecutable)

	isUpstart, err := upstart.IsRunning()
	c.Assert(isUpstart, jc.IsFalse)
	c.Assert(err, gc.ErrorMatches, ".+: permission denied")
}
示例#2
0
文件: upstart_test.go 项目: bac/juju
func (s *IsRunningSuite) TestUpstartNotInstalled(c *gc.C) {
	s.PatchValue(upstart.InitctlPath, "/foo/bar/not-exist")

	isUpstart, err := upstart.IsRunning()
	c.Assert(isUpstart, jc.IsFalse)
	c.Assert(err, jc.ErrorIsNil)
}
示例#3
0
文件: upstart_test.go 项目: bac/juju
func (s *IsRunningSuite) TestUpstartInstalled(c *gc.C) {
	s.createInitctl(c, "", 0, modeExecutable)

	isUpstart, err := upstart.IsRunning()
	c.Assert(isUpstart, jc.IsTrue)
	c.Assert(err, jc.ErrorIsNil)
}
示例#4
0
文件: upstart_test.go 项目: bac/juju
func (s *IsRunningSuite) TestUpstartInstalledButNotRunning(c *gc.C) {
	const stderr = `Name "com.ubuntu.Upstart" does not exist`
	const errorCode = 1
	s.createInitctl(c, stderr, errorCode, modeExecutable)

	isUpstart, err := upstart.IsRunning()
	c.Assert(isUpstart, jc.IsFalse)
	c.Assert(err, gc.ErrorMatches, fmt.Sprintf(".*exit status %d", errorCode))
}
示例#5
0
文件: upstart_test.go 项目: bac/juju
func (s *IsRunningSuite) TestUpstartInstalledButBroken(c *gc.C) {
	const stderr = "<something broke>"
	const errorCode = 99
	s.createInitctl(c, stderr, errorCode, modeExecutable)

	isUpstart, err := upstart.IsRunning()
	c.Assert(isUpstart, jc.IsFalse)
	c.Assert(err, gc.ErrorMatches, fmt.Sprintf(".*exit status %d", errorCode))
}