Esempio n. 1
0
				}))
			})

			It("updates the message status as failed", func() {
				v1Process.Deliver(job, logger)

				Expect(messageStatusUpdater.UpdateCall.Receives.Connection).To(Equal(conn))
				Expect(messageStatusUpdater.UpdateCall.Receives.MessageID).To(Equal(messageID))
				Expect(messageStatusUpdater.UpdateCall.Receives.MessageStatus).To(Equal(postal.StatusFailed))
				Expect(messageStatusUpdater.UpdateCall.Receives.Logger.SessionName()).To(Equal("notifications.worker"))
			})
		})

		Context("when the job contains malformed JSON", func() {
			BeforeEach(func() {
				job.Payload = `{"Space":"my-space","Options":{"HTML":"<p>some text that just abruptly ends`
			})

			It("does not crash the process", func() {
				Expect(func() {
					v1Process.Deliver(job, logger)
				}).ToNot(Panic())
			})

			It("marks the job for retry later", func() {
				v1Process.Deliver(job, logger)

				Expect(deliveryFailureHandler.HandleCall.Receives.Job).To(Equal(job))
				Expect(deliveryFailureHandler.HandleCall.Receives.Logger.SessionName()).To(Equal("notifications.worker"))
			})
		})