示例#1
0
			receivedCounter = metricsreporter.NewCounter("received")
			internalMetricsCounter = metricsreporter.NewCounter("internal metrics")
			reader = fakeReader{}
			legacyReader = legacyreader.NewLegacyReader(receivedCounter, internalMetricsCounter, &reader)
		})

		It("should report legacy log messages", func() {
			reader.event = messagegenerator.BasicLogMessageEnvelope("legacy", "appID")

			legacyReader.Read()

			Expect(receivedCounter.GetValue()).To(BeEquivalentTo(1))
		})

		It("should report value metrics", func() {
			reader.event = messagegenerator.BasicValueMetricEnvelope("test-origin")

			legacyReader.Read()

			Expect(receivedCounter.GetValue()).To(BeEquivalentTo(1))
		})

		It("should only count test log messages", func() {
			reader.event = messagegenerator.BasicLogMessageEnvelope("non-test-origin", "appID")

			legacyReader.Read()

			Expect(receivedCounter.GetValue()).To(BeEquivalentTo(0))
		})

		It("should only count test value metrics", func() {
var _ = Describe("ValueMetricReader", func() {
	Context("Read", func() {
		var (
			receivedCounter   *metricsreporter.Counter
			reader            fakeReader
			valueMetricReader *valuemetricreader.ValueMetricReader
		)

		BeforeEach(func() {
			receivedCounter = metricsreporter.NewCounter("counter")
			reader = fakeReader{}
			valueMetricReader = valuemetricreader.NewValueMetricReader(receivedCounter, &reader)
		})

		It("should report value metrics", func() {
			reader.event = messagegenerator.BasicValueMetricEnvelope(valuemetricreader.TestOrigin)

			valueMetricReader.Read()

			Expect(receivedCounter.GetValue()).To(BeEquivalentTo(1))
		})

		It("should not report log messages", func() {
			reader.event = messagegenerator.BasicLogMessageEnvelope(valuemetricreader.TestOrigin, "appID")

			valueMetricReader.Read()

			Expect(receivedCounter.GetValue()).To(BeEquivalentTo(0))
		})

		It("should only report test value metrics", func() {