Expect(controller.DeleteTaskCallCount()).To(Equal(1)) _, taskGuid := controller.DeleteTaskArgsForCall(0) Expect(taskGuid).To(Equal("task-guid")) Expect(responseRecorder.Code).To(Equal(http.StatusOK)) response := &models.TaskLifecycleResponse{} err := response.Unmarshal(responseRecorder.Body.Bytes()) Expect(err).NotTo(HaveOccurred()) Expect(response.Error).To(BeNil()) }) }) Context("when the controller returns an unrecoverable error", func() { BeforeEach(func() { controller.DeleteTaskReturns(models.NewUnrecoverableError(nil)) }) It("logs and writes to the exit channel", func() { Eventually(logger).Should(gbytes.Say("unrecoverable-error")) Eventually(exitCh).Should(Receive()) }) }) Context("when desiring the task fails", func() { BeforeEach(func() { controller.DeleteTaskReturns(models.ErrUnknownError) }) It("responds with an error", func() { Expect(responseRecorder.Code).To(Equal(http.StatusOK))