hugottest

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2020 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter struct {
	*ResponseRecorder
	*MessagePlayer
}

Adapter provides a test adapter you can preload with messages, and retrieve messages from.

func NewAdapter

func NewAdapter(in chan *hugot.Message, out chan hugot.Message) *Adapter

NewAdapter creates a new Adapter, preloaded with the provided set of messages

type MessagePlayer

type MessagePlayer struct {
	MessagesIn chan *hugot.Message
}

MessagePlayer can be used to pass a channel of messages into a bot.

func (*MessagePlayer) Receive

func (mp *MessagePlayer) Receive() <-chan *hugot.Message

Receive will return a mesasge from the player's channel.

type ResponseRecorder

type ResponseRecorder struct {
	MessagesOut chan hugot.Message
	// contains filtered or unexported fields
}

ResponseRecorder will send all messages a handler writes to it out of the provided channel.

func (*ResponseRecorder) Send

func (rr *ResponseRecorder) Send(ctx context.Context, m *hugot.Message)

Send is called to send a message to the recorder's channel.

func (*ResponseRecorder) SetChannel

func (rr *ResponseRecorder) SetChannel(c string)

SetChannel is used to decide which channel data sent use Write will be sent on.

func (*ResponseRecorder) SetTo

func (rr *ResponseRecorder) SetTo(to string)

SetTo tells the record who to send data sent with Write to.

func (*ResponseRecorder) Write

func (rr *ResponseRecorder) Write(bs []byte) (int, error)

Wrtie implement io.Write, but sending data written to it as a single hugot.Message.

Jump to

Keyboard shortcuts

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