本文整理汇总了Golang中github.com/cloudfoundry/bosh-agent/agent/applier/applyspec/fakes.FakeV1Service.GetErr方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeV1Service.GetErr方法的具体用法?Golang FakeV1Service.GetErr怎么用?Golang FakeV1Service.GetErr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/bosh-agent/agent/applier/applyspec/fakes.FakeV1Service
的用法示例。
在下文中一共展示了FakeV1Service.GetErr方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
_, err := action.Run()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(Equal("At least one job template is required to run an errand"))
})
It("does not run errand script", func() {
_, err := action.Run()
Expect(err).To(HaveOccurred())
Expect(len(cmdRunner.RunComplexCommands)).To(Equal(0))
})
})
})
Context("when apply spec could not be retrieved", func() {
BeforeEach(func() {
specService.GetErr = errors.New("fake-get-error")
})
It("returns error stating that job template is required", func() {
_, err := action.Run()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-get-error"))
})
It("does not run errand script", func() {
_, err := action.Run()
Expect(err).To(HaveOccurred())
Expect(len(cmdRunner.RunComplexCommands)).To(Equal(0))
})
})
})
示例2: init
//.........这里部分代码省略.........
handler.SendCallback = func(_ fakembus.SendInput) {
sentRequests++
if sentRequests == 3 {
handler.SendErr = errors.New("stop")
}
}
err := agent.Run()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("stop"))
Expect(handler.SendInputs()).To(Equal([]fakembus.SendInput{
{
Target: boshhandler.HealthMonitor,
Topic: boshhandler.Heartbeat,
Message: expectedHb,
},
{
Target: boshhandler.HealthMonitor,
Topic: boshhandler.Heartbeat,
Message: expectedHb,
},
{
Target: boshhandler.HealthMonitor,
Topic: boshhandler.Heartbeat,
Message: expectedHb,
},
}))
})
})
Context("when the agent fails to get job spec for a heartbeat", func() {
BeforeEach(func() {
specService.GetErr = errors.New("fake-spec-service-error")
handler.KeepOnRunning()
})
It("returns the error", func() {
err := agent.Run()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-spec-service-error"))
})
})
Context("when the agent fails to get vitals for a heartbeat", func() {
BeforeEach(func() {
platform.FakeVitalsService.GetErr = errors.New("fake-vitals-service-error")
handler.KeepOnRunning()
})
It("returns the error", func() {
err := agent.Run()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-vitals-service-error"))
})
})
It("sends job monitoring alerts to health manager", func() {
handler.KeepOnRunning()
monitAlert := boshalert.MonitAlert{
ID: "fake-monit-alert",
Service: "fake-service",
Event: "fake-event",
Action: "fake-action",
Date: "Sun, 22 May 2011 20:07:41 +0500",
示例3: init
//.........这里部分代码省略.........
Expect(specService.Spec).To(Equal(currentApplySpec))
})
})
})
Context("when resolving dynamic networks fails", func() {
BeforeEach(func() {
specService.PopulateDHCPNetworksErr = errors.New("fake-populate-dynamic-networks-err")
})
It("returns error", func() {
_, err := action.Run(desiredApplySpec)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-populate-dynamic-networks-err"))
})
It("does not apply desired spec as current spec", func() {
_, err := action.Run(desiredApplySpec)
Expect(err).To(HaveOccurred())
Expect(applier.Applied).To(BeFalse())
})
It("does not save desired spec as current spec", func() {
_, err := action.Run(desiredApplySpec)
Expect(err).To(HaveOccurred())
Expect(specService.Spec).To(Equal(currentApplySpec))
})
})
})
Context("when current spec cannot be retrieved", func() {
BeforeEach(func() {
specService.Spec = currentApplySpec
specService.GetErr = errors.New("fake-get-error")
})
It("returns error and does not apply desired spec", func() {
_, err := action.Run(desiredApplySpec)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-get-error"))
})
It("does not run applier with desired spec", func() {
_, err := action.Run(desiredApplySpec)
Expect(err).To(HaveOccurred())
Expect(applier.Applied).To(BeFalse())
})
It("does not save desired spec as current spec", func() {
_, err := action.Run(desiredApplySpec)
Expect(err).To(HaveOccurred())
Expect(specService.Spec).To(Equal(currentApplySpec))
})
})
})
Context("when desired spec does not have a configuration hash", func() {
desiredApplySpec := boshas.V1ApplySpec{
JobSpec: boshas.JobSpec{
Template: "fake-job-template",
},
}
populatedDesiredApplySpec := boshas.V1ApplySpec{
JobSpec: boshas.JobSpec{
Template: "fake-populated-job-template",
示例4: init
//.........这里部分代码省略.........
Expect(specService.Spec).To(Equal(currentApplySpec))
})
})
})
Context("when resolving dynamic networks fails", func() {
BeforeEach(func() {
specService.PopulateDynamicNetworksErr = errors.New("fake-populate-dynamic-networks-err")
})
It("returns error", func() {
_, err := action.Run(desiredApplySpec)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-populate-dynamic-networks-err"))
})
It("does not apply desired spec as current spec", func() {
_, err := action.Run(desiredApplySpec)
Expect(err).To(HaveOccurred())
Expect(applier.Applied).To(BeFalse())
})
It("does not save desired spec as current spec", func() {
_, err := action.Run(desiredApplySpec)
Expect(err).To(HaveOccurred())
Expect(specService.Spec).To(Equal(currentApplySpec))
})
})
})
Context("when current spec cannot be retrieved", func() {
BeforeEach(func() {
specService.Spec = currentApplySpec
specService.GetErr = errors.New("fake-get-error")
})
It("returns error and does not apply desired spec", func() {
_, err := action.Run(desiredApplySpec)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-get-error"))
})
It("does not run applier with desired spec", func() {
_, err := action.Run(desiredApplySpec)
Expect(err).To(HaveOccurred())
Expect(applier.Applied).To(BeFalse())
})
It("does not save desired spec as current spec", func() {
_, err := action.Run(desiredApplySpec)
Expect(err).To(HaveOccurred())
Expect(specService.Spec).To(Equal(currentApplySpec))
})
})
})
Context("when desired spec does not have a configuration hash", func() {
desiredApplySpec := boshas.V1ApplySpec{
JobSpec: boshas.JobSpec{
Template: "fake-job-template",
},
}
populatedDesiredApplySpec := boshas.V1ApplySpec{
JobSpec: boshas.JobSpec{
Template: "fake-populated-job-template",