本文整理汇总了Golang中metron/writers/mocks.MockByteArrayWriter类的典型用法代码示例。如果您正苦于以下问题:Golang MockByteArrayWriter类的具体用法?Golang MockByteArrayWriter怎么用?Golang MockByteArrayWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MockByteArrayWriter类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
"github.com/cloudfoundry/dropsonde/metric_sender/fake"
"github.com/cloudfoundry/loggregatorlib/loggertesthelper"
"github.com/cloudfoundry/dropsonde/metricbatcher"
"github.com/cloudfoundry/dropsonde/metrics"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"strconv"
"time"
)
var _ = Describe("NetworkReader", func() {
var reader *networkreader.NetworkReader
var readerStopped chan struct{}
var writer mocks.MockByteArrayWriter
var port int
var address string
var fakeMetricSender *fake.FakeMetricSender
BeforeEach(func() {
port = 3456 + GinkgoParallelNode()
address = net.JoinHostPort("127.0.0.1", strconv.Itoa(port))
writer = mocks.MockByteArrayWriter{}
reader = networkreader.New(address, "networkReader", &writer, loggertesthelper.Logger())
readerStopped = make(chan struct{})
})
Context("with a reader running", func() {
BeforeEach(func() {
loggertesthelper.TestLoggerSink.Clear()
示例2:
"github.com/cloudfoundry/dropsonde/factories"
"github.com/cloudfoundry/dropsonde/metric_sender/fake"
"github.com/cloudfoundry/dropsonde/metricbatcher"
"github.com/cloudfoundry/dropsonde/metrics"
"github.com/cloudfoundry/loggregatorlib/cfcomponent/instrumentation/testhelpers"
"github.com/cloudfoundry/loggregatorlib/loggertesthelper"
"github.com/cloudfoundry/sonde-go/events"
"github.com/gogo/protobuf/proto"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"time"
)
var _ = Describe("EventMarshaller", func() {
var (
marshaller *eventmarshaller.EventMarshaller
writer *mocks.MockByteArrayWriter
)
BeforeEach(func() {
writer = &mocks.MockByteArrayWriter{}
marshaller = eventmarshaller.New(writer, loggertesthelper.Logger())
})
It("marshals envelopes into bytes", func() {
envelope := &events.Envelope{
Origin: proto.String("fake-origin-1"),
EventType: events.Envelope_LogMessage.Enum(),
LogMessage: factories.NewLogMessage(events.LogMessage_OUT, "message", "appid", "sourceType"),
}
message, _ := proto.Marshal(envelope)