func (s *LifeSuite) prepareFixture(living state.Living, lfix lifeFixture, cached, dbinitial state.Life, c *gc.C) { collName, id := lfix.id() coll := s.MgoSuite.Session.DB("juju").C(collName) err := coll.UpdateId(id, bson.D{{"$set", bson.D{ {"life", cached}, }}}) c.Assert(err, gc.IsNil) err = living.Refresh() c.Assert(err, gc.IsNil) err = coll.UpdateId(id, bson.D{{"$set", bson.D{ {"life", dbinitial}, }}}) c.Assert(err, gc.IsNil) }
func assertRemoved(c *gc.C, entity state.Living) { err := entity.Refresh() c.Assert(err, jc.Satisfies, errors.IsNotFound) err = entity.Destroy() c.Assert(err, gc.IsNil) if entity, ok := entity.(state.AgentLiving); ok { err = entity.EnsureDead() c.Assert(err, gc.IsNil) err = entity.Remove() c.Assert(err, gc.IsNil) } }
func assertLife(c *gc.C, entity state.Living, life state.Life) { c.Assert(entity.Refresh(), gc.IsNil) c.Assert(entity.Life(), gc.Equals, life) }