Example #1
0
		gosteno.EnterTestMode()
		testingSink = gosteno.GetMeTheGlobalTestSink()

		fakeStore = fakestoreadapter.New()
		logger = gosteno.NewLogger("test")
	})

	Context("at initialization", func() {
		It("connects to the store", func() {
			elector.NewElector("name", fakeStore, 1*time.Millisecond, logger)
			Expect(fakeStore.DidConnect).To(BeTrue())
		})

		Context("when store connection fails", func() {
			BeforeEach(func() {
				fakeStore.ConnectErr = errors.New("connection error")
			})

			It("logs an error", func() {
				go elector.NewElector("name", fakeStore, 100*time.Millisecond, logger)

				Eventually(func() int { return len(testingSink.Records()) }).Should(BeNumerically(">=", 1))
				var messages []string
				for _, record := range testingSink.Records() {
					messages = append(messages, record.Message)
				}

				Expect(messages).To(ContainElement("Elector: Unable to connect to store: 'connection error'"))
			})

			It("reconnects on an interval", func() {