コード例 #1
0
ファイル: filter_test.go プロジェクト: hivetech/judo.legacy
func (s *FilterSuite) TestUnitDeath(c *C) {
	f, err := newFilter(s.State, s.unit.Name())
	c.Assert(err, IsNil)
	defer f.Stop()
	asserter := coretesting.NotifyAsserterC{
		Precond: func() { s.State.StartSync() },
		C:       c,
		Chan:    f.UnitDying(),
	}
	asserter.AssertNoReceive()

	// Irrelevant change.
	err = s.unit.SetResolved(state.ResolvedRetryHooks)
	c.Assert(err, IsNil)
	asserter.AssertNoReceive()

	// Set dying.
	err = s.unit.SetStatus(params.StatusStarted, "")
	c.Assert(err, IsNil)
	err = s.unit.Destroy()
	c.Assert(err, IsNil)
	asserter.AssertClosed()

	// Another irrelevant change.
	err = s.unit.ClearResolved()
	c.Assert(err, IsNil)
	asserter.AssertClosed()

	// Set dead.
	err = s.unit.EnsureDead()
	c.Assert(err, IsNil)
	s.assertAgentTerminates(c, f)
}
コード例 #2
0
ファイル: filter_test.go プロジェクト: hivetech/judo.legacy
// Ensure we get a signal on f.Dead()
func (s *FilterSuite) assertFilterDies(c *C, f *filter) {
	asserter := coretesting.NotifyAsserterC{
		Precond: func() { s.State.StartSync() },
		C:       c,
		Chan:    f.Dead(),
	}
	asserter.AssertClosed()
}