Exemple #1
0
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")
}
Exemple #2
0
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)
}
Exemple #3
0
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)
}
Exemple #4
0
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))
}
Exemple #5
0
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))
}