// NewRelationer creates a new Relationer. The unit will not join the // relation until explicitly requested. func NewRelationer(ru *state.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 *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(), DeepEquals, expect) if deleted { _, err := os.Stat(filepath.Join(relsdir, strconv.Itoa(relationId))) c.Assert(os.IsNotExist(err), Equals, true) } else { fresh, err := relation.ReadStateDir(relsdir, relationId) c.Assert(err, IsNil) c.Assert(fresh.State(), DeepEquals, expect) } }