コード例 #1
0
ファイル: task_runner_test.go プロジェクト: rowhit/lattice
			err := taskRunner.DeleteTask("task-guid-1")
			Expect(err).To(MatchError("task-guid-1 is not in COMPLETED state"))
		})

		Context("when the receptor returns errors", func() {
			It("bubbles up the error from task_examiner.TaskStatus", func() {
				fakeTaskExaminer.TaskStatusReturns(task_examiner.TaskInfo{}, errors.New("Task not found"))

				err := taskRunner.DeleteTask("task-guid-1")
				Expect(err).To(MatchError("Task not found"))
			})

			It("returns error when not able to delete the task", func() {
				fakeTaskExaminer.TaskStatusReturns(getTaskStatus(receptor.TaskStateCompleted), nil)
				fakeReceptorClient.DeleteTaskReturns(errors.New("task in unknown state"))

				err := taskRunner.DeleteTask("task-guid-1")
				Expect(err).To(MatchError("task in unknown state"))
			})
		})
	})

	Describe("Cancel Task", func() {
		getTaskStatus := func(state string) task_examiner.TaskInfo {
			return task_examiner.TaskInfo{
				TaskGuid: "task-guid-1",
				State:    state,
			}
		}