Пример #1
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()

	worker, err := applicationscaler.New(config)
	c.Check(worker, gc.IsNil)
Пример #2
// 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)
	select {
	case <-done:
	case <-time.After(coretesting.LongWait):
		c.Fatalf("test func timed out")