Beispiel #1
0
			sender.ScanLogStream("someId", "app", "0", reader)

			Expect(emitter.GetMessages()).To(HaveLen(2))
			messages := emitter.GetMessages()

			Expect(getLogmessage(messages[0].Event)).To(Equal("one"))
			Expect(getLogmessage(messages[1].Event)).To(Equal("two"))
		})
	})

	Describe("ScanErrorLogStream", func() {

		It("sends lines from stream to emitter", func() {
			buf := bytes.NewBufferString("line 1\nline 2\n")

			sender.ScanErrorLogStream("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_ERR))
			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_ERR))
		})
var _ = Describe("ScanErrorLogStream", 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.ScanErrorLogStream("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_ERR))
		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_ERR))
	})