func (s *notifyWorkerSuite) TestErrorsOnClosedChannel(c *gc.C) { foundErr := fmt.Errorf("did not get an error") triggeredHandler := func(errer watcher.Errer) error { foundErr = errer.Err() return foundErr } worker.SetEnsureErr(triggeredHandler) s.actor.watcher.Stop() err := waitShort(c, s.worker) // If the foundErr is nil, we would have panic-ed (see TestDefaultClosedHandler) c.Check(foundErr, gc.IsNil) c.Check(err, jc.ErrorIsNil) s.actor.CheckActions(c, "setup", "teardown") }
func (s *notifyWorkerSuite) TestErrorsOnStillAliveButClosedChannel(c *gc.C) { foundErr := fmt.Errorf("did not get an error") triggeredHandler := func(errer watcher.Errer) error { foundErr = errer.Err() return foundErr } worker.SetEnsureErr(triggeredHandler) s.actor.watcher.SetStopError(tomb.ErrStillAlive) s.actor.watcher.Stop() err := waitShort(c, s.worker) c.Check(foundErr, gc.Equals, tomb.ErrStillAlive) // ErrStillAlive is trapped by the Stop logic and gets turned into a // 'nil' when stopping. However TestDefaultClosedHandler can assert // that it would have triggered a panic. c.Check(err, jc.ErrorIsNil) s.actor.CheckActions(c, "setup", "teardown") // Worker is stopped, don't fail TearDownTest s.worker = nil }
func (s *notifyWorkerSuite) TearDownTest(c *gc.C) { worker.SetEnsureErr(nil) s.stopWorker(c) s.BaseSuite.TearDownTest(c) }