本文整理汇总了Golang中github.com/cloudfoundry/bosh-agent/agent/task/fakes.FakeService.CreateTaskErr方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeService.CreateTaskErr方法的具体用法?Golang FakeService.CreateTaskErr怎么用?Golang FakeService.CreateTaskErr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/bosh-agent/agent/task/fakes.FakeService
的用法示例。
在下文中一共展示了FakeService.CreateTaskErr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: init
//.........这里部分代码省略.........
Expect(err).ToNot(HaveOccurred())
Expect(action.Canceled).To(BeTrue())
})
It("returns error from cancelling task if canceling task fails", func() {
action.CancelErr = errors.New("fake-cancel-err")
dispatcher.Dispatch(req)
err := taskService.StartedTasks["fake-generated-task-id"].Cancel()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-cancel-err"))
})
}
Context("when action is not persistent", func() {
BeforeEach(func() {
action.Persistent = false
})
It("responds with task id and state", func() {
resp := dispatcher.Dispatch(req)
boshassert.MatchesJSONString(GinkgoT(), resp,
`{"value":{"agent_task_id":"fake-generated-task-id","state":"running"}}`)
})
It("starts running created task", func() {
dispatcher.Dispatch(req)
Expect(len(taskService.StartedTasks)).To(Equal(1))
Expect(taskService.StartedTasks["fake-generated-task-id"]).ToNot(BeNil())
})
It("returns create task error", func() {
taskService.CreateTaskErr = errors.New("fake-create-task-error")
resp := dispatcher.Dispatch(req)
respJSON, err := json.Marshal(resp)
Expect(err).ToNot(HaveOccurred())
Expect(string(respJSON)).To(ContainSubstring("fake-create-task-error"))
})
It("return run value to the task", func() {
actionRunner.RunValue = "fake-value"
dispatcher.Dispatch(req)
value, err := taskService.StartedTasks["fake-generated-task-id"].Func()
Expect(value).To(Equal("fake-value"))
Expect(err).ToNot(HaveOccurred())
Expect(actionRunner.RunAction).To(Equal(action))
Expect(string(actionRunner.RunPayload)).To(Equal("fake-payload"))
})
It("returns run error to the task", func() {
actionRunner.RunErr = errors.New("fake-run-error")
dispatcher.Dispatch(req)
value, err := taskService.StartedTasks["fake-generated-task-id"].Func()
Expect(value).To(BeNil())
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-run-error"))
Expect(actionRunner.RunAction).To(Equal(action))
Expect(string(actionRunner.RunPayload)).To(Equal("fake-payload"))
})
ItAllowsToCancelTask()