Context("when the receptor returns errors", func() { It("returns error when getting existing tasks", func() { fakeReceptorClient.TasksReturns(nil, errors.New("unable to fetch tasks")) err := taskRunner.CreateTask(createTaskParams) Expect(err).To(MatchError("unable to fetch tasks")) Expect(fakeReceptorClient.TasksCallCount()).To(Equal(1)) Expect(fakeReceptorClient.UpsertDomainCallCount()).To(Equal(0)) Expect(fakeReceptorClient.CreateTaskCallCount()).To(Equal(0)) }) It("returns error when upserting the domain", func() { upsertError := errors.New("You're not that fresh, buddy.") fakeReceptorClient.UpsertDomainReturns(upsertError) err := taskRunner.CreateTask(createTaskParams) Expect(err).To(MatchError(upsertError)) Expect(fakeReceptorClient.TasksCallCount()).To(Equal(1)) Expect(fakeReceptorClient.UpsertDomainCallCount()).To(Equal(1)) Expect(fakeReceptorClient.CreateTaskCallCount()).To(Equal(0)) }) It("returns error when creating the task fails", func() { fakeReceptorClient.CreateTaskReturns(errors.New("not making your task")) err := taskRunner.CreateTask(createTaskParams) Expect(err).To(MatchError("not making your task"))