JustBeforeEach(func() { err = controller.ResolvingTask(logger, taskGuid) }) Context("when resolvinging the task succeeds", func() { It("returns no error", func() { Expect(fakeTaskDB.ResolvingTaskCallCount()).To(Equal(1)) _, taskGuid := fakeTaskDB.ResolvingTaskArgsForCall(0) Expect(taskGuid).To(Equal("task-guid")) Expect(err).NotTo(HaveOccurred()) }) }) Context("when desiring the task fails", func() { BeforeEach(func() { fakeTaskDB.ResolvingTaskReturns(errors.New("kaboom")) }) It("responds with an error", func() { Expect(err).To(MatchError("kaboom")) }) }) }) }) Describe("DeleteTask", func() { Context("when the delete request is normal", func() { var ( taskGuid string err error )
task *models.Task httpClient *http.Client ) BeforeEach(func() { httpClient = cfhttp.NewClient() statusCodes = make(chan int) fakeServer.RouteToHandler("POST", "/the-callback/url", func(w http.ResponseWriter, req *http.Request) { w.WriteHeader(<-statusCodes) }) callbackURL = fakeServer.URL() + "/the-callback/url" taskDB = new(dbfakes.FakeTaskDB) taskDB.ResolvingTaskReturns(nil) taskDB.DeleteTaskReturns(nil) }) simulateTaskCompleting := func(signals <-chan os.Signal, ready chan<- struct{}) error { close(ready) task = model_helpers.NewValidTask("the-task-guid") task.CompletionCallbackUrl = callbackURL taskworkpool.HandleCompletedTask(logger, httpClient, taskDB, task) return nil } var process ifrit.Process JustBeforeEach(func() { process = ifrit.Invoke(ifrit.RunFunc(simulateTaskCompleting)) })