本文整理匯總了Golang中github.com/juju/juju/apiserver/presence.Config.Validate方法的典型用法代碼示例。如果您正苦於以下問題:Golang Config.Validate方法的具體用法?Golang Config.Validate怎麽用?Golang Config.Validate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/juju/juju/apiserver/presence.Config
的用法示例。
在下文中一共展示了Config.Validate方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestConfigValidateZeroValue
func (s *WorkerSuite) TestConfigValidateZeroValue(c *gc.C) {
var cfg presence.Config
err := cfg.Validate()
c.Check(err, gc.NotNil)
}
示例2: TestConfigValidateMissingIdentity
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`)
}
示例3: TestConfigValidateOkay
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)
}
示例4: TestConfigValidateMissingRetryDelay
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`)
}
示例5: TestConfigValidateMissingClock
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`)
}
示例6: TestConfigValidateMissingStart
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`)
}
示例7: TestConfigValidateNothingUsed
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)
}
示例8: checkInvalid
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)
}