Esempio n. 1
0
			}
			fakeReceptorClient.GetTaskReturns(getTaskResponse, nil)
		})

		It("returns a task status", func() {
			taskInfo, err := taskExaminer.TaskStatus("boop")
			Expect(err).ToNot(HaveOccurred())
			Expect(taskInfo.TaskGuid).To(Equal("boop"))
			Expect(taskInfo.State).To(Equal(receptor.TaskStateCompleted))
			Expect(taskInfo.CellID).To(Equal("cell-01"))
			Expect(taskInfo.Failed).To(BeFalse())
			Expect(taskInfo.FailureReason).To(BeEmpty())
			Expect(taskInfo.Result).To(Equal("some-result"))

			Expect(fakeReceptorClient.GetTaskCallCount()).To(Equal(1))
			Expect(fakeReceptorClient.GetTaskArgsForCall(0)).To(Equal("boop"))
		})

		Context("when the receptor returns errors", func() {
			It("returns exists false for TaskNotFound", func() {
				receptorError := receptor.Error{Type: receptor.TaskNotFound, Message: "could not locate this"}
				fakeReceptorClient.GetTaskReturns(receptor.TaskResponse{}, receptorError)

				_, err := taskExaminer.TaskStatus("boop1")
				Expect(err).To(MatchError(task_examiner.TaskNotFoundErrorMessage))
			})

			It("bubbles up error for receptor Error anything but TaskNotFound", func() {
				receptorError := receptor.Error{Type: receptor.TaskGuidAlreadyExists, Message: "could not locate this"}
				fakeReceptorClient.GetTaskReturns(receptor.TaskResponse{}, receptorError)