Exemplo n.º 1
0
				LogMessage: &events.LogMessage{
					Message:     []byte{4, 5, 6},
					MessageType: events.LogMessage_OUT.Enum(),
					Timestamp:   proto.Int64(123),
					AppId:       proto.String("fake-app-id"),
				},
			}))
		})

		It("does not put an envelope on the output channel if there is unmarshal error", func() {
			unmarshaller.Write([]byte{1, 2, 3})
			Expect(writer.Events).To(BeEmpty())
		})
	})

	Context("metrics", func() {
		BeforeEach(func() {
			unmarshaller = legacyunmarshaller.New(&writer, loggertesthelper.Logger())
		})

		It("emits the correct metrics context", func() {
			Expect(unmarshaller.Emit().Name).To(Equal("legacyUnmarshaller"))
		})

		It("emits an unmarshal error counter", func() {
			unmarshaller.Write([]byte{1, 2, 3})
			testhelpers.EventuallyExpectMetric(unmarshaller, "unmarshalErrors", 1)
		})
	})
})