// NewRelationer creates a new Relationer. The unit will not join the // relation until explicitly requested. func NewRelationer(ru *apiuniter.RelationUnit, dir *relation.StateDir, hooks chan<- hook.Info) *Relationer { return &Relationer{ ctx: NewContextRelation(ru, dir.State().Members), ru: ru, dir: dir, hooks: hooks, } }
func assertState(c *gc.C, dir *relation.StateDir, relsdir string, relationId int, members msi, pending string, deleted bool) { expect := &relation.State{ RelationId: relationId, Members: map[string]int64(members), ChangedPending: pending, } c.Assert(dir.State(), gc.DeepEquals, expect) if deleted { _, err := os.Stat(filepath.Join(relsdir, strconv.Itoa(relationId))) c.Assert(err, jc.Satisfies, os.IsNotExist) } else { fresh, err := relation.ReadStateDir(relsdir, relationId) c.Assert(err, gc.IsNil) c.Assert(fresh.State(), gc.DeepEquals, expect) } }