// StartHooks starts watching the relation, and sending hook.Info events on the // hooks channel. It will panic if called when already responding to relation // changes. func (r *Relationer) StartHooks() { if r.IsImplicit() { return } if r.queue != nil { panic("hooks already started!") } if r.dying { r.queue = relation.NewDyingHookQueue(r.dir.State(), r.hooks) } else { r.queue = relation.NewAliveHookQueue(r.dir.State(), r.hooks, r.ru.Watch()) } }
func (s *HookQueueSuite) TestDyingHookQueue(c *C) { for i, t := range dyingHookQueueTests { c.Logf("test %d: %s", i, t.summary) out := make(chan hook.Info) q := relation.NewDyingHookQueue(t.initial, out) for i, step := range t.steps { c.Logf(" step %d", i) step.check(c, nil, out) } expect{}.check(c, nil, out) q.Stop() } }