本文整理匯總了Golang中bosh/settings/fakes.FakeSettingsService.Ips方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeSettingsService.Ips方法的具體用法?Golang FakeSettingsService.Ips怎麽用?Golang FakeSettingsService.Ips使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類bosh/settings/fakes.FakeSettingsService
的用法示例。
在下文中一共展示了FakeSettingsService.Ips方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: init
func init() {
Describe("concreteBuilder", func() {
var (
settingsService *fakesettings.FakeSettingsService
builder Builder
)
BeforeEach(func() {
logger := boshlog.NewLogger(boshlog.LEVEL_NONE)
settingsService = &fakesettings.FakeSettingsService{}
builder = NewBuilder(settingsService, logger)
})
Describe("Build", func() {
It("builds alert with id, severity and other monit related info", func() {
builtAlert, err := builder.Build(buildMonitAlert())
Expect(err).ToNot(HaveOccurred())
expectedAlert := Alert{
Id: "some random id",
Severity: SEVERITY_ALERT,
Title: "nats - does not exist - restart",
Summary: "process is not running",
CreatedAt: 1306076861,
}
Expect(builtAlert).To(Equal(expectedAlert))
})
It("sets the severity based on event", func() {
alerts := map[string]SeverityLevel{
"action done": SEVERITY_IGNORED,
"Action done": SEVERITY_IGNORED,
"action Done": SEVERITY_IGNORED,
}
for event, expectedSeverity := range alerts {
inputAlert := buildMonitAlert()
inputAlert.Event = event
builtAlert, _ := builder.Build(inputAlert)
Expect(builtAlert.Severity).To(Equal(expectedSeverity))
}
})
It("sets default severity to critical", func() {
inputAlert := buildMonitAlert()
inputAlert.Event = "some unknown event"
builtAlert, _ := builder.Build(inputAlert)
Expect(builtAlert.Severity).To(Equal(SEVERITY_CRITICAL))
})
It("sets created at", func() {
inputAlert := buildMonitAlert()
inputAlert.Date = "Thu, 02 May 2013 20:07:41 +0500"
builtAlert, _ := builder.Build(inputAlert)
Expect(int(builtAlert.CreatedAt)).To(Equal(int(1367507261)))
})
It("defaults created at to now on parse error", func() {
inputAlert := buildMonitAlert()
inputAlert.Date = "Thu, 02 May 2013 20:07:0"
builtAlert, _ := builder.Build(inputAlert)
createdAt := time.Unix(builtAlert.CreatedAt, 0)
now := time.Now()
assert.WithinDuration(GinkgoT(), now, createdAt, 1*time.Second)
})
It("sets the title with ips", func() {
inputAlert := buildMonitAlert()
settingsService.Ips = []string{"192.168.0.1", "10.0.0.1"}
builtAlert, _ := builder.Build(inputAlert)
Expect(builtAlert.Title).To(Equal("nats (10.0.0.1, 192.168.0.1) - does not exist - restart"))
})
})
})
}