func (s *ValueWorkerSuite) TestNewValueWorker_Success(c *gc.C) { w, err := util.NewValueWorker("cheese") c.Assert(err, jc.ErrorIsNil) err = worker.Stop(w) c.Check(err, jc.ErrorIsNil) }
// clockManifold expresses a Clock as a ValueWorker manifold. func clockManifold(clock clock.Clock) dependency.Manifold { return dependency.Manifold{ Start: func(_ dependency.GetResourceFunc) (worker.Worker, error) { return util.NewValueWorker(clock) }, Output: util.ValueWorkerOutput, } }
// newWorker creates a degenerate worker that provides access to an fslock. func newWorker(a agent.Agent) (worker.Worker, error) { dataDir := a.CurrentConfig().DataDir() lock, err := createLock(dataDir) if err != nil { return nil, errors.Trace(err) } return util.NewValueWorker(lock) }
func (s *ValueWorkerSuite) TestValueWorkerOutput_BadOutputType(c *gc.C) { value := &testType{} w, err := util.NewValueWorker(value) c.Assert(err, jc.ErrorIsNil) var outVal string err = util.ValueWorkerOutput(w, &outVal) c.Check(err, gc.ErrorMatches, "cannot output into \\*string") c.Check(outVal, gc.Equals, "") }
func (s *ValueWorkerSuite) TestValueWorkerOutput_BadOutputIndirection(c *gc.C) { value := &testType{} w, err := util.NewValueWorker(value) c.Assert(err, jc.ErrorIsNil) var outVal string err = util.ValueWorkerOutput(w, outVal) c.Check(err, gc.ErrorMatches, "out should be a pointer; is .*") c.Check(outVal, gc.Equals, "") }
func (s *ValueWorkerSuite) TestValueWorkerOutput_Success(c *gc.C) { value := &testType{} w, err := util.NewValueWorker(value) c.Assert(err, jc.ErrorIsNil) var outVal testInterface err = util.ValueWorkerOutput(w, &outVal) c.Check(err, jc.ErrorIsNil) c.Check(outVal, gc.DeepEquals, value) }
func (s *ValueWorkerSuite) TestNewValueWorker_NilValue(c *gc.C) { w, err := util.NewValueWorker(nil) c.Check(err, gc.ErrorMatches, "NewValueWorker expects a value") c.Check(w, gc.IsNil) }