本文整理匯總了Golang中bosh/settings/directories.DirectoriesProvider.MonitJobsDir方法的典型用法代碼示例。如果您正苦於以下問題:Golang DirectoriesProvider.MonitJobsDir方法的具體用法?Golang DirectoriesProvider.MonitJobsDir怎麽用?Golang DirectoriesProvider.MonitJobsDir使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類bosh/settings/directories.DirectoriesProvider
的用法示例。
在下文中一共展示了DirectoriesProvider.MonitJobsDir方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: init
//.........這裏部分代碼省略.........
Description: "process is not running",
})
})
It("monitor job failures ignores other emails", func() {
var didHandleAlert bool
failureHandler := func(alert boshalert.MonitAlert) (err error) {
didHandleAlert = true
return
}
go monit.MonitorJobFailures(failureHandler)
msg := `Hi! How'sit goin`
err := doJobFailureEmail(msg, jobFailuresServerPort)
Expect(err).ToNot(HaveOccurred())
Expect(didHandleAlert).To(BeFalse())
})
Describe("AddJob", func() {
BeforeEach(func() {
fs.WriteFileString("/some/config/path", "fake-config")
})
Context("when reading configuration from config path succeeds", func() {
Context("when writing job configuration succeeds", func() {
It("returns no error because monit can track added job in jobs directory", func() {
err := monit.AddJob("router", 0, "/some/config/path")
Expect(err).ToNot(HaveOccurred())
writtenConfig, err := fs.ReadFileString(
dirProvider.MonitJobsDir() + "/0000_router.monitrc")
Expect(err).ToNot(HaveOccurred())
Expect(writtenConfig).To(Equal("fake-config"))
})
})
Context("when writing job configuration fails", func() {
It("returns error", func() {
fs.WriteToFileError = errors.New("fake-write-error")
err := monit.AddJob("router", 0, "/some/config/path")
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-write-error"))
})
})
})
Context("when reading configuration from config path fails", func() {
It("returns error", func() {
fs.ReadFileError = errors.New("fake-read-error")
err := monit.AddJob("router", 0, "/some/config/path")
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-read-error"))
})
})
})
Describe("RemoveAllJobs", func() {
Context("when jobs directory removal succeeds", func() {
It("does not return error because all jobs are removed from monit", func() {
jobsDir := dirProvider.MonitJobsDir()
jobBasename := "/0000_router.monitrc"
示例2:
})
})
Describe("AddJob", func() {
BeforeEach(func() {
fs.WriteFileString("/some/config/path", "fake-config")
})
Context("when reading configuration from config path succeeds", func() {
Context("when writing job configuration succeeds", func() {
It("returns no error because monit can track added job in jobs directory", func() {
err := monit.AddJob("router", 0, "/some/config/path")
Expect(err).ToNot(HaveOccurred())
writtenConfig, err := fs.ReadFileString(
dirProvider.MonitJobsDir() + "/0000_router.monitrc")
Expect(err).ToNot(HaveOccurred())
Expect(writtenConfig).To(Equal("fake-config"))
})
})
Context("when writing job configuration fails", func() {
It("returns error", func() {
fs.WriteToFileError = errors.New("fake-write-error")
err := monit.AddJob("router", 0, "/some/config/path")
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-write-error"))
})
})
})