Example #1
0
	Describe("DeleteTask", func() {
		Context("when the delete request is normal", func() {
			BeforeEach(func() {
				requestBody = &models.TaskGuidRequest{
					TaskGuid: "task-guid",
				}
			})
			JustBeforeEach(func() {
				request := newTestRequest(requestBody)
				handler.DeleteTask(responseRecorder, request)
			})

			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(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 desiring the task fails", func() {
				BeforeEach(func() {
					fakeTaskDB.DeleteTaskReturns(models.ErrUnknownError)
				})
Example #2
0
							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() {