Ejemplo n.º 1
0
		JustBeforeEach(func() {
			handler.CancelTask(logger, responseRecorder, request)
			Expect(responseRecorder.Code).To(Equal(http.StatusOK))
		})

		Context("when the cancel request is normal", func() {
			Context("when canceling the task in the controller succeeds", func() {
				BeforeEach(func() {
					cellPresence := models.CellPresence{CellId: "cell-id"}
					fakeServiceClient.CellByIdReturns(&cellPresence, nil)
				})

				It("returns no error", func() {
					Expect(controller.CancelTaskCallCount()).To(Equal(1))
					taskLogger, taskGuid := controller.CancelTaskArgsForCall(0)
					Expect(taskLogger.SessionName()).To(ContainSubstring("cancel-task"))
					Expect(taskGuid).To(Equal("task-guid"))

					response := &models.TaskLifecycleResponse{}
					err := response.Unmarshal(responseRecorder.Body.Bytes())
					Expect(err).NotTo(HaveOccurred())

					Expect(response.Error).To(BeNil())
				})
			})

			Context("when cancelling the task fails", func() {
				BeforeEach(func() {
					controller.CancelTaskReturns(models.ErrUnknownError)
				})