Exemple #1
0
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, "")
}
Exemple #2
0
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, "")
}
Exemple #3
0
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)
}
Exemple #4
0
func (s *ValueWorkerSuite) TestValueWorkerOutput_BadInput(c *gc.C) {
	var outVal testInterface
	err := util.ValueWorkerOutput(&testType{}, &outVal)
	c.Check(err, gc.ErrorMatches, "in should be a \\*valueWorker; is .*")
	c.Check(outVal, gc.IsNil)
}