Exemple #1
0
func (s *WorkerSuite) TestConfigValidateZeroValue(c *gc.C) {
	var cfg presence.Config

	err := cfg.Validate()

	c.Check(err, gc.NotNil)
}
Exemple #2
0
func (s *WorkerSuite) TestConfigValidateMissingIdentity(c *gc.C) {
	cfg := presence.Config{
		Start:      func() (presence.Pinger, error) { return nil, nil },
		Clock:      struct{ clock.Clock }{},
		RetryDelay: time.Second,
	}

	err := cfg.Validate()

	c.Check(err, jc.Satisfies, errors.IsNotValid)
	c.Check(err, gc.ErrorMatches, `nil Identity not valid`)
}
Exemple #3
0
func (s *WorkerSuite) TestConfigValidateOkay(c *gc.C) {
	cfg := presence.Config{
		Identity:   names.NewMachineTag("1"),
		Start:      func() (presence.Pinger, error) { return nil, nil },
		Clock:      struct{ clock.Clock }{},
		RetryDelay: time.Second,
	}

	err := cfg.Validate()

	c.Check(err, jc.ErrorIsNil)
}
Exemple #4
0
func (s *WorkerSuite) TestConfigValidateMissingRetryDelay(c *gc.C) {
	cfg := presence.Config{
		Identity: names.NewMachineTag("1"),
		Start:    func() (presence.Pinger, error) { return nil, nil },
		Clock:    struct{ clock.Clock }{},
	}

	err := cfg.Validate()

	c.Check(err, jc.Satisfies, errors.IsNotValid)
	c.Check(err, gc.ErrorMatches, `non-positive RetryDelay not valid`)
}
Exemple #5
0
func (s *WorkerSuite) TestConfigValidateMissingClock(c *gc.C) {
	cfg := presence.Config{
		Identity:   names.NewMachineTag("1"),
		Start:      func() (presence.Pinger, error) { return nil, nil },
		RetryDelay: time.Second,
	}

	err := cfg.Validate()

	c.Check(err, jc.Satisfies, errors.IsNotValid)
	c.Check(err, gc.ErrorMatches, `nil Clock not valid`)
}
Exemple #6
0
func (s *WorkerSuite) TestConfigValidateMissingStart(c *gc.C) {
	cfg := presence.Config{
		Identity:   names.NewMachineTag("1"),
		Clock:      struct{ clock.Clock }{},
		RetryDelay: time.Second,
	}

	err := cfg.Validate()

	c.Check(err, jc.Satisfies, errors.IsNotValid)
	c.Check(err, gc.ErrorMatches, `nil Start not valid`)
}
Exemple #7
0
func (s *WorkerSuite) TestConfigValidateNothingUsed(c *gc.C) {
	cfg := presence.Config{
		Identity:   names.NewMachineTag("1"),
		Start:      s.start,
		Clock:      coretesting.NewStubClock(s.stub),
		RetryDelay: time.Second,
	}

	err := cfg.Validate()
	c.Assert(err, jc.ErrorIsNil)

	s.stub.CheckNoCalls(c)
}
Exemple #8
0
func checkInvalid(c *gc.C, config presence.Config, message string) {
	check := func(err error) {
		c.Check(err, gc.ErrorMatches, message)
		c.Check(err, jc.Satisfies, errors.IsNotValid)
	}

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

	worker, err := presence.New(config)
	if !c.Check(worker, gc.IsNil) {
		workertest.CleanKill(c, worker)
	}
	check(err)
}