func (s *WorkerSuite) TestConfigValidateZeroValue(c *gc.C) { var cfg presence.Config err := cfg.Validate() c.Check(err, gc.NotNil) }
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`) }
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) }
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`) }
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`) }
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`) }
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) }
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) }