func (s *WorkerSuite) TestValidate(c *gc.C) { config := servicescaler.Config{} check := func(err error) { c.Check(err, gc.ErrorMatches, "nil Facade not valid") c.Check(err, jc.Satisfies, errors.IsNotValid) } err := config.Validate() check(err) worker, err := servicescaler.New(config) check(err) c.Check(worker, gc.IsNil) }
// Run will create a servicescaler worker; start recording the calls // it makes; and pass it to the supplied test func, which will be invoked // on a new goroutine. If Run returns, it is safe to inspect the recorded // calls via the embedded testing.Stub. func (fix *fixture) Run(c *gc.C, test func(worker.Worker)) { stubFacade := newFacade(&fix.Stub) scaler, err := servicescaler.New(servicescaler.Config{ Facade: stubFacade, }) c.Assert(err, jc.ErrorIsNil) done := make(chan struct{}) go func() { defer close(done) defer worker.Stop(scaler) test(scaler) }() select { case <-done: case <-time.After(coretesting.LongWait): c.Fatalf("test func timed out") } }