Documentation
¶
Overview ¶
Package testing provides test helpers for chit.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EchoProcessor ¶
EchoProcessor returns a processor that echoes the input as a response.
Types ¶
type CollectingEmitter ¶
type CollectingEmitter struct {
Messages []chit.Message
Resources []chit.Resource
// contains filtered or unexported fields
}
CollectingEmitter collects all emitted content for easy assertion.
func (*CollectingEmitter) Close ¶
func (e *CollectingEmitter) Close() error
Close implements chit.Emitter.
func (*CollectingEmitter) Content ¶
func (e *CollectingEmitter) Content() string
Content returns all emitted message content concatenated.
type MockEmitter ¶
type MockEmitter struct {
// EmitFunc is called when Emit is invoked.
EmitFunc func(ctx context.Context, msg chit.Message) error
// PushFunc is called when Push is invoked.
PushFunc func(ctx context.Context, resource chit.Resource) error
// CloseFunc is called when Close is invoked.
CloseFunc func() error
// Messages records all emitted messages.
Messages []chit.Message
// Resources records all pushed resources.
Resources []chit.Resource
// Closed indicates whether Close was called.
Closed bool
// contains filtered or unexported fields
}
MockEmitter is a test implementation of chit.Emitter.
type MockProcessor ¶
type MockProcessor struct {
// ProcessFunc is called when Process is invoked.
// Set this to control the mock's behavior.
ProcessFunc func(ctx context.Context, input string, history []chit.Message) (chit.Result, error)
// Calls records all calls to Process for verification.
Calls []ProcessCall
// contains filtered or unexported fields
}
MockProcessor is a test implementation of chit.Processor.
type ProcessCall ¶
ProcessCall records a single call to Process.
Click to show internal directories.
Click to hide internal directories.