Expect(responseRecorder.Code).To(Equal(http.StatusInternalServerError)) }) It("does not try to resolve the task", func() { handler.Delete(responseRecorder, request) Expect(fakeClient.ResolveTaskCallCount()).To(BeZero()) }) }) }) Context("when task cannot be resolved", func() { BeforeEach(func() { var err error request, err = http.NewRequest("", "http://example.com?:task_guid=the-task-guid", nil) Expect(err).NotTo(HaveOccurred()) fakeClient.ResolveTaskReturns(errors.New("Failed to resolve task")) }) It("responds with an error", func() { handler.Delete(responseRecorder, request) Expect(responseRecorder.Code).To(Equal(http.StatusInternalServerError)) }) }) }) Describe("Cancel", func() { BeforeEach(func() { var err error request, err = http.NewRequest("", "http://example.com?:task_guid=the-task-guid", nil) Expect(err).NotTo(HaveOccurred()) })