taskGuid string err error ) BeforeEach(func() { taskGuid = "task-guid" }) JustBeforeEach(func() { err = controller.DeleteTask(logger, taskGuid) }) Context("when deleting the task succeeds", func() { It("returns no error", func() { Expect(fakeTaskDB.DeleteTaskCallCount()).To(Equal(1)) _, taskGuid := fakeTaskDB.DeleteTaskArgsForCall(0) Expect(taskGuid).To(Equal("task-guid")) Expect(err).NotTo(HaveOccurred()) }) }) Context("when desiring the task fails", func() { BeforeEach(func() { fakeTaskDB.DeleteTaskReturns(errors.New("kaboom")) }) It("responds with an error", func() { Expect(err).To(MatchError("kaboom")) }) }) })
var response models.TaskCallbackResponse err = json.Unmarshal(data, &response) Expect(err).NotTo(HaveOccurred()) Expect(response.CreatedAt).To(Equal(task.CreatedAt)) Expect(response.TaskGuid).To(Equal("the-task-guid")) Expect(response.CreatedAt).To(Equal(task.CreatedAt)) }) }) It("resolves the task", func() { statusCodes <- 200 Eventually(taskDB.DeleteTaskCallCount).Should(Equal(1)) _, actualGuid := taskDB.DeleteTaskArgsForCall(0) Expect(actualGuid).To(Equal("the-task-guid")) }) }) Context("when the request fails with a 4xx response code", func() { It("resolves the task", func() { statusCodes <- 403 Eventually(taskDB.DeleteTaskCallCount).Should(Equal(1)) _, actualGuid := taskDB.DeleteTaskArgsForCall(0) Expect(actualGuid).To(Equal("the-task-guid")) }) }) Context("when the request fails with a 500 response code", func() {