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") }
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) }
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) }
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)) }
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)) }