State: "COMPLETED", } fakeTaskExaminer.TaskStatusReturns(taskInfo, nil) test_helpers.ExecuteCommandWithArgs(cancelTaskCommand, []string{"task-guid-1"}) Expect(outputBuffer).To(test_helpers.SayLine(colors.Green("OK"))) }) It("returns error when fail to cancel the task", func() { taskInfo := task_examiner.TaskInfo{ TaskGuid: "task-guid-1", State: "COMPLETED", } fakeTaskExaminer.TaskStatusReturns(taskInfo, nil) fakeTaskRunner.CancelTaskReturns(errors.New("task in unknown state")) test_helpers.ExecuteCommandWithArgs(cancelTaskCommand, []string{"task-guid-1"}) Expect(outputBuffer).To(test_helpers.SayLine(colors.Red("Error cancelling task-guid-1: " + "task in unknown state"))) Expect(fakeExitHandler.ExitCalledWith).To(Equal([]int{exit_codes.CommandFailed})) }) It("fails with usage", func() { test_helpers.ExecuteCommandWithArgs(cancelTaskCommand, []string{}) Expect(outputBuffer).To(test_helpers.SayLine("Please input a valid <task-guid>")) Expect(fakeExitHandler.ExitCalledWith).To(Equal([]int{exit_codes.InvalidSyntax})) }) }) })