Example #1
0
func (s *ValueWorkerSuite) TestNewValueWorker_Success(c *gc.C) {
	w, err := engine.NewValueWorker("cheese")
	c.Assert(err, jc.ErrorIsNil)

	err = worker.Stop(w)
	c.Check(err, jc.ErrorIsNil)
}
Example #2
0
// clockManifold expresses a Clock as a ValueWorker manifold.
func clockManifold(clock clock.Clock) dependency.Manifold {
	return dependency.Manifold{
		Start: func(_ dependency.Context) (worker.Worker, error) {
			return engine.NewValueWorker(clock)
		},
		Output: engine.ValueWorkerOutput,
	}
}
Example #3
0
func (s *ValueWorkerSuite) TestValueWorkerOutput_BadOutputType(c *gc.C) {
	value := &testType{}
	w, err := engine.NewValueWorker(value)
	c.Assert(err, jc.ErrorIsNil)

	var outVal string
	err = engine.ValueWorkerOutput(w, &outVal)
	c.Check(err, gc.ErrorMatches, "cannot output into \\*string")
	c.Check(outVal, gc.Equals, "")
}
Example #4
0
func (s *ValueWorkerSuite) TestValueWorkerOutput_BadOutputIndirection(c *gc.C) {
	value := &testType{}
	w, err := engine.NewValueWorker(value)
	c.Assert(err, jc.ErrorIsNil)

	var outVal string
	err = engine.ValueWorkerOutput(w, outVal)
	c.Check(err, gc.ErrorMatches, "out should be a pointer; is .*")
	c.Check(outVal, gc.Equals, "")
}
Example #5
0
func (s *ValueWorkerSuite) TestValueWorkerOutput_Success(c *gc.C) {
	value := &testType{}
	w, err := engine.NewValueWorker(value)
	c.Assert(err, jc.ErrorIsNil)

	var outVal testInterface
	err = engine.ValueWorkerOutput(w, &outVal)
	c.Check(err, jc.ErrorIsNil)
	c.Check(outVal, gc.DeepEquals, value)
}
Example #6
0
func (s *ValueWorkerSuite) TestNewValueWorker_NilValue(c *gc.C) {
	w, err := engine.NewValueWorker(nil)
	c.Check(err, gc.ErrorMatches, "NewValueWorker expects a value")
	c.Check(w, gc.IsNil)
}