testutils

package
v0.0.0-...-05a97e5 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultNodeID used in the ProcessingContext
	DefaultNodeID = "node"

	// DefaultActorName of the test actor
	DefaultActorName = "actor"
)

Variables

View Source
var (
	// DefaultProcessID used in the ProcessingContext
	DefaultProcessID = api.MustUUIDFromString("af75efb0-1f0d-11e9-9513-2329a2a94eaf")
	// DefaultActorID of the test actor
	DefaultActorID = api.MustUUIDFromString("7fe4f2b8-1f0e-11e9-8661-ebbdab78f251")
)

Functions

This section is empty.

Types

type ActorServiceTester

type ActorServiceTester struct {
	Apc xbus.ActorProcessingContext

	Outputs map[string]*xbus.EnvelopeReceiver
	// contains filtered or unexported fields
}

ActorServiceTester helps testing a ActorProcessService service

func NewActorServiceTester

func NewActorServiceTester(
	t *testing.T,
	serviceName string,
	factory func(actor *xbus.Actor) xbus.ActorService,
) *ActorServiceTester

NewActorServiceTester creates a ActorServiceTester

func (*ActorServiceTester) CloseInput

func (t *ActorServiceTester) CloseInput(name string)

CloseInput marks an input as closed

func (*ActorServiceTester) FeedInput

func (t *ActorServiceTester) FeedInput(name string, fragment api.Envelope)

FeedInput adds a fragment to an input stream. Must be called _during_ Run to avoid being locked

func (*ActorServiceTester) GetOutputEnvelope

func (t *ActorServiceTester) GetOutputEnvelope(name string, timeout time.Duration) (*api.Envelope, error)

GetOutputEnvelope returns the complete envelope send on a given output Run must be over

func (*ActorServiceTester) GetOutputReceiver

func (t *ActorServiceTester) GetOutputReceiver(name string) *xbus.EnvelopeReceiver

GetOutputReceiver returns an envelope receiver for envelope send on a given output

func (*ActorServiceTester) RunProcess

func (t *ActorServiceTester) RunProcess() (*api.ActorProcessingState, error)

RunProcess runs Process() with the inputs if provided and store the outputs for further inspection

func (*ActorServiceTester) SetInputEnvelope

func (t *ActorServiceTester) SetInputEnvelope(name string, fragment *api.Envelope)

SetInputEnvelope associate an initial envelope fragment to an input If needed, further fragments can be fed during the RunProcess() with FeedInput

func (*ActorServiceTester) SetSettings

func (t *ActorServiceTester) SetSettings(settings map[string]interface{})

SetSettings sets the service settings in the Actor definition

type ExpectedError

type ExpectedError struct {
	MatchMessage MatchMessage
	Name         string
}

ExpectedError is the definition of an expected error

func ExpectsContains

func ExpectsContains(value string) ExpectedError

ExpectsContains returns a ExpectedError matching a partial message

func ExpectsEqual

func ExpectsEqual(value string) ExpectedError

ExpectsEqual returns a ExpectedError matching a message exactly

type MatchMessage

type MatchMessage func(string) bool

MatchMessage is a function that match a log message

type TestAPCLogger

type TestAPCLogger struct {
	// contains filtered or unexported fields
}

TestAPCLogger ...

func (*TestAPCLogger) EnvErrorf

func (l *TestAPCLogger) EnvErrorf(env *api.Envelope, format string, args ...interface{})

EnvErrorf logs a error message

func (*TestAPCLogger) EnvNoticef

func (l *TestAPCLogger) EnvNoticef(env *api.Envelope, format string, args ...interface{})

EnvNoticef logs a notice message

func (*TestAPCLogger) EnvWarningf

func (l *TestAPCLogger) EnvWarningf(env *api.Envelope, format string, args ...interface{})

EnvWarningf logs a warning message

func (*TestAPCLogger) Errorf

func (l *TestAPCLogger) Errorf(format string, args ...interface{})

Errorf logs a error message

func (*TestAPCLogger) Noticef

func (l *TestAPCLogger) Noticef(format string, args ...interface{})

Noticef logs a notice message

func (*TestAPCLogger) Warningf

func (l *TestAPCLogger) Warningf(format string, args ...interface{})

Warningf logs a warning message

type TestLogger

type TestLogger struct {
	// contains filtered or unexported fields
}

TestLogger is a BusLogger for tests

func GetTestLogger

func GetTestLogger(t testing.TB) *TestLogger

GetTestLogger returns a new BusLogger for the passed testing.T

func (TestLogger) Debugf

func (m TestLogger) Debugf(format string, v ...interface{})

Debugf passes the message to T.Logf

func (*TestLogger) Errorf

func (m *TestLogger) Errorf(format string, v ...interface{})

Errorf passes the message to T.Errorf

func (*TestLogger) ExpectsError

func (m *TestLogger) ExpectsError(expectedError interface{})

ExpectsError anticipate an error and make it non-fatal to the test

func (TestLogger) Fatalf

func (m TestLogger) Fatalf(format string, v ...interface{})

Fatalf passes the message to T.Fatalf

func (TestLogger) Noticef

func (m TestLogger) Noticef(format string, v ...interface{})

Noticef passes the message to T.Logf

func (*TestLogger) SetTest

func (m *TestLogger) SetTest(t testing.TB) func()

SetTest changes the current test, and return a function to cancel the change

func (TestLogger) Tracef

func (m TestLogger) Tracef(format string, v ...interface{})

Tracef passes the message to T.Logf

func (TestLogger) VerifyExpectations

func (m TestLogger) VerifyExpectations()

VerifyExpectations enforce error expectations

Jump to

Keyboard shortcuts

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