コード例 #1
0
ファイル: runner_test.go プロジェクト: felicianotech/juju
func (s *workersSuite) TestStartError(c *gc.C) {
	runner := workertesting.NewStubRunner(s.stub)
	failure := errors.Errorf("<failed>")
	s.stub.SetErrors(nil, failure)

	workers := worker.NewWorkers()
	expected := []string{"spam", "eggs", "ham"}
	for _, id := range expected {
		err := workers.Add(id, s.newWorkerFunc(id))
		c.Assert(err, jc.ErrorIsNil)
	}
	err := workers.Start(runner)

	s.stub.CheckCallNames(c, "StartWorker", "StartWorker")
	c.Check(errors.Cause(err), gc.Equals, failure)
}
コード例 #2
0
ファイル: runner_test.go プロジェクト: felicianotech/juju
func (s *workersSuite) TestStartOkay(c *gc.C) {
	runner := workertesting.NewStubRunner(s.stub)
	runner.CallWhenStarted = true

	workers := worker.NewWorkers()
	expected := []string{"spam", "eggs", "ham"}
	for _, id := range expected {
		err := workers.Add(id, s.newWorkerFunc(id))
		c.Assert(err, jc.ErrorIsNil)
	}
	err := workers.Start(runner)
	c.Assert(err, jc.ErrorIsNil)

	// We would use s.stub.CheckCalls if functions could be compared...
	runner.CheckCallIDs(c, "StartWorker", expected...)
	sort.Strings(s.calls)
	sort.Strings(expected)
	c.Check(s.calls, jc.DeepEquals, expected)
}