示例#1
0
func (s *OriginalRelationUnitSuite) assertChange(
	c *C, w *state.RelationUnitsWatcher,
	joined []string,
	changed map[string]map[string]interface{},
	departed []string,
) {
	s.State.StartSync()
	select {
	case ch, ok := <-w.Changes():
		if !ok {
			c.Fatalf("channel closed; watcher error: %#v", w.Err())
		}
		sort.Strings(joined)
		sort.Strings(ch.Joined)
		c.Assert(joined, DeepEquals, ch.Joined)
		c.Assert(len(changed), Equals, len(ch.Changed))
		for name, m := range changed {
			c.Assert(ch.Changed[name].Settings, DeepEquals, m)
		}
		sort.Strings(departed)
		sort.Strings(ch.Departed)
		c.Assert(departed, DeepEquals, ch.Departed)
	case <-time.After(5 * time.Second):
		c.Fatalf("expected joined %#v, changed %#v, departed %#v; got nothing", joined, changed, departed)
	}
}
示例#2
0
func (s *OriginalRelationUnitSuite) assertNoChange(c *C, w *state.RelationUnitsWatcher) {
	s.State.StartSync()
	select {
	case ch := <-w.Changes():
		c.Fatalf("got %#v, expected nothing", ch)
	case <-time.After(50 * time.Millisecond):
	}
}