envelope = &events.Envelope{ Origin: proto.String("fake-origin-1"), EventType: events.Envelope_LogMessage.Enum(), LogMessage: factories.NewLogMessage(events.LogMessage_OUT, "message", "appid", "sourceType"), } }) AfterEach(func() { forwarder.Stop() <-doneChan }) Context("client selection", func() { It("selects a random client", func() { forwarder.Write(envelope) Eventually(func() int { return clientPool.RandomClientCallCount() }).Should(Equal(1)) }) Context("when selecting a client errors", func() { It("an error is logged and returns", func() { clientPool.RandomClientReturns(nil, errors.New("boom")) forwarder.Write(envelope) Eventually(loggertesthelper.TestLoggerSink.LogContents).Should(ContainSubstring("can't forward message")) Eventually(client.SchemeCallCount).Should(Equal(0)) }) }) }) Context("udp client", func() { BeforeEach(func() {
logger = loggertesthelper.Logger() loggertesthelper.TestLoggerSink.Clear() forwarder = dopplerforwarder.New(clientPool, sharedSecret, logger) envelope = &events.Envelope{ Origin: proto.String("fake-origin-1"), EventType: events.Envelope_LogMessage.Enum(), LogMessage: factories.NewLogMessage(events.LogMessage_OUT, "message", "appid", "sourceType"), } }) Context("client selection", func() { It("selects a random client", func() { forwarder.Write(envelope) Expect(clientPool.RandomClientCallCount()).To(Equal(1)) }) Context("when selecting a client errors", func() { It("an error is logged and returns", func() { clientPool.RandomClientReturns(nil, errors.New("boom")) forwarder.Write(envelope) Expect(loggertesthelper.TestLoggerSink.LogContents()).To(ContainSubstring("can't forward message")) Expect(client.SchemeCallCount()).To(Equal(0)) }) }) }) Context("udp client", func() { BeforeEach(func() {