pubsubtest

package
v0.0.0-...-a1bf982 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2016 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TestPublishMsg

type TestPublishMsg struct {
	// Key represents the message key.
	Key string
	// Body represents the message body.
	Body []byte
}

TestPublishMsg is a test publish message.

type TestPublisher

type TestPublisher struct {
	// Published will contain a list of all messages that have been published.
	Published []TestPublishMsg

	// GivenError will be returned by the TestPublisher on publish.
	// Good for testing error scenarios.
	GivenError error

	// FoundError will contain any errors encountered while marshalling
	// the protobuf struct.
	FoundError error
}

TestPublisher is a simple implementation of pubsub.Publisher meant to help mock out any implementations.

func (*TestPublisher) Publish

func (t *TestPublisher) Publish(key string, msg proto.Message) error

Publish publishes the message, delegating to PublishRaw.

func (*TestPublisher) PublishRaw

func (t *TestPublisher) PublishRaw(key string, msg []byte) error

PublishRaw publishes the raw message byte slice.

type TestSubsMessage

type TestSubsMessage struct {
	Msg   []byte
	Doned bool
}

TestSubsMessage represents a test subscriber message.

func (*TestSubsMessage) Done

func (m *TestSubsMessage) Done() error

Done sets the Doned field to true.

func (*TestSubsMessage) Message

func (m *TestSubsMessage) Message() []byte

Message returns the subscriber message.

type TestSubscriber

type TestSubscriber struct {
	// ProtoMessages will be marshalled into []byte and used to mock out
	// a feed if it is populated.
	ProtoMessages []proto.Message

	// JSONMessages will be marshalled into []byte and used to mock out
	// a feed if it is populated.
	JSONMessages []interface{}

	// GivenErrError will be returned by the TestSubscriber on Err().
	// Good for testing error scenarios.
	GivenErrError error

	// GivenStopError will be returned by the TestSubscriber on Stop().
	// Good for testing error scenarios.
	GivenStopError error

	// FoundError will contain any errors encountered while marshalling
	// the JSON and protobuf struct.
	FoundError error
}

TestSubscriber is a simple implementation of pubsub.Subscriber meant to help mock out any implementations.

func (*TestSubscriber) Err

func (t *TestSubscriber) Err() error

Err returns the GivenErrError value.

func (*TestSubscriber) Start

func (t *TestSubscriber) Start() <-chan pubsub.SubscriberMessage

Start will populate and return the test channel for the subscriber

func (*TestSubscriber) Stop

func (t *TestSubscriber) Stop() error

Stop returns the GivenStopError value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL