import (
	"fmt"
	"tools/benchmark/metricsreporter"

	"time"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gbytes"
)

var _ = Describe("MetricsReporter", func() {
	var (
		buffer   *gbytes.Buffer
		reporter *metricsreporter.MetricsReporter
		start    time.Time
		counters []*metricsreporter.Counter
	)

	JustBeforeEach(func() {
		buffer = gbytes.NewBuffer()
		reporter = metricsreporter.New(time.Millisecond*10, buffer, counters...)
		start = time.Now()
		go reporter.Start()
	})

	AfterEach(func() {
		buffer.Close()
	})

	Describe("SentCounter", func() {
예제 #2
0
package metricsreporter_test

import (
	"tools/benchmark/metricsreporter"

	"time"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gbytes"
)

var _ = Describe("MetricsReporter", func() {
	var buffer *gbytes.Buffer
	var reporter *metricsreporter.MetricsReporter

	Context("with no additional counters", func() {
		BeforeEach(func() {
			buffer = gbytes.NewBuffer()
			reporter = metricsreporter.New(time.Millisecond*10, buffer)
			go reporter.Start()
		})

		AfterEach(func() {
			buffer.Close()
		})

		It("should increment sent counter", func() {
			reporter.GetSentCounter().IncrementValue()
			reporter.GetSentCounter().IncrementValue()
			Eventually(buffer).Should(gbytes.Say("2, 0"))