It("should hand the job to the v2 workflow", func() { worker.Deliver(job) Expect(v2Workflow.DeliverCall.Receives.Delivery).To(Equal(postal.Delivery{ MessageID: "some-message-id", CampaignID: "some-campaign-id", })) Expect(v2Workflow.DeliverCall.Receives.Logger).NotTo(BeNil()) Expect(v1Workflow.DeliverCall.CallCount).To(Equal(0)) }) Context("when the workflow encounters an error", func() { It("updates the message status to retry if the job should be retried", func() { v2Workflow.DeliverCall.Returns.Error = errors.New("delivery failure") job.ShouldRetry = true worker.Deliver(job) Expect(deliveryFailureHandler.HandleCall.Receives.Job).To(Equal(job)) Expect(deliveryFailureHandler.HandleCall.Receives.Logger).NotTo(BeNil()) Expect(messageStatusUpdater.UpdateCall.Receives.Connection).To(Equal(connection)) Expect(messageStatusUpdater.UpdateCall.Receives.MessageID).To(Equal("some-message-id")) Expect(messageStatusUpdater.UpdateCall.Receives.CampaignID).To(Equal("some-campaign-id")) Expect(messageStatusUpdater.UpdateCall.Receives.MessageStatus).To(Equal("retry")) }) It("updates the message status to failed if the job should not be retried", func() { v2Workflow.DeliverCall.Returns.Error = errors.New("delivery failure") job.ShouldRetry = false