Exemplo n.º 1
0
func (fix *fixture) Run(c *gc.C, test func(worker.Worker)) {
	stubRetryStrategy := params.RetryStrategy{
		ShouldRetry: true,
	}
	stubTag := stubTag{}
	stubFacade := newStubFacade(c, &fix.Stub, stubRetryStrategy, stubTag)
	stubConfig := retrystrategy.WorkerConfig{
		Facade:        stubFacade,
		AgentTag:      stubTag,
		RetryStrategy: stubRetryStrategy,
	}

	w, err := retrystrategy.NewRetryStrategyWorker(stubConfig)
	c.Assert(err, jc.ErrorIsNil)
	done := make(chan struct{})
	go func() {
		defer close(done)
		defer worker.Stop(w)
		test(w)
	}()

	select {
	case <-done:
	case <-time.After(coretesting.LongWait):
		c.Fatalf("test timed out")
	}
}
Exemplo n.º 2
0
func (s *WorkerSuite) testValidate(c *gc.C, config retrystrategy.WorkerConfig, errMsg string) {
	check := func(err error) {
		c.Check(err, gc.ErrorMatches, errMsg)
		c.Check(err, jc.Satisfies, errors.IsNotValid)
	}

	err := config.Validate()
	check(err)

	worker, err := retrystrategy.NewRetryStrategyWorker(config)
	check(err)
	c.Check(worker, gc.IsNil)
}