} }) 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() { client.SchemeReturns("udp") }) It("marshals, signs, writes and emits metrics", func() { bytes, err := proto.Marshal(envelope) Expect(err).NotTo(HaveOccurred()) bytes = signature.SignMessage(bytes, sharedSecret) forwarder.Write(envelope)