Example #1
0
func (s *WorkerSuite) TestValidate(c *gc.C) {
	config := applicationscaler.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 := applicationscaler.New(config)
	check(err)
	c.Check(worker, gc.IsNil)
}
Example #2
0
// Run will create an applicationscaler 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 := applicationscaler.New(applicationscaler.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")
	}
}