本文整理匯總了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()