Describe("SendAppErrorLog", func() { It("sends an error when log error messages cannot be emitted", func() { err := sender.SendAppErrorLog("app-id", "custom-log-error-message", "App", "0") Expect(err).To(HaveOccurred()) }) }) }) Describe("ScanLogStream", func() { It("sends lines from stream to emitter", func() { buf := bytes.NewBufferString("line 1\nline 2\n") sender.ScanLogStream("someId", "app", "0", buf) messages := emitter.GetMessages() Expect(messages).To(HaveLen(2)) log := emitter.Messages[0].Event.(*events.LogMessage) Expect(log.GetMessage()).To(BeEquivalentTo("line 1")) Expect(log.GetMessageType()).To(Equal(events.LogMessage_OUT)) Expect(log.GetAppId()).To(Equal("someId")) Expect(log.GetSourceType()).To(Equal("app")) Expect(log.GetSourceInstance()).To(Equal("0")) log = emitter.Messages[1].Event.(*events.LogMessage) Expect(log.GetMessage()).To(BeEquivalentTo("line 2")) Expect(log.GetMessageType()).To(Equal(events.LogMessage_OUT)) })
var _ = Describe("ScanLogStream", func() { var ( emitter *fake.FakeEventEmitter sender log_sender.LogSender ) BeforeEach(func() { emitter = fake.NewFakeEventEmitter("origin") sender = log_sender.NewLogSender(emitter, loggertesthelper.Logger()) }) It("sends lines from stream to emitter", func() { buf := bytes.NewBufferString("line 1\nline 2\n") sender.ScanLogStream("someId", "app", "0", buf, nil) messages := emitter.GetMessages() Expect(messages).To(HaveLen(2)) log := emitter.Messages[0].Event.(*events.LogMessage) Expect(log.GetMessage()).To(BeEquivalentTo("line 1")) Expect(log.GetMessageType()).To(Equal(events.LogMessage_OUT)) Expect(log.GetAppId()).To(Equal("someId")) Expect(log.GetSourceType()).To(Equal("app")) Expect(log.GetSourceInstance()).To(Equal("0")) log = emitter.Messages[1].Event.(*events.LogMessage) Expect(log.GetMessage()).To(BeEquivalentTo("line 2")) Expect(log.GetMessageType()).To(Equal(events.LogMessage_OUT)) })