Пример #1
0
		Context("and it is not time to send the message yet", func() {
			BeforeEach(func() {
				timeProvider = fakeclock.NewFakeClock(time.Unix(129, 0))
			})

			It("should not error", func() {
				Expect(err).NotTo(HaveOccurred())
			})

			It("should not send the messages", func() {
				Expect(messageBus.PublishedMessages("hm9000.start")).To(HaveLen(0))
			})

			It("should not increment the metrics", func() {
				Expect(pendingStartMessages(metricsAccountant.IncrementSentMessageMetricsArgsForCall(0))).To(HaveLen(0))
			})

			It("should leave the messages in the queue", func() {
				messages, _ := store.GetPendingStartMessages()
				Expect(messages).To(HaveLen(1))
			})
		})

		Context("and it is time to send the message", func() {
			BeforeEach(func() {
				timeProvider = fakeclock.NewFakeClock(time.Unix(130, 0))
			})

			It("should send the message", func() {
				Expect(messageBus.PublishedMessages("hm9000.start")).To(HaveLen(1))