Documentation ¶
Overview ¶
Package fakeirc implements a fake IRC server for testing.
Index ¶
- Constants
- Variables
- func TagChannel(m *irc.Message, channel string) *irc.Message
- type Helper
- func (h *Helper) Addr() string
- func (h *Helper) AssertMessages(gotP *[]*irc.Message, want ...*irc.Message)
- func (h *Helper) CloseConn(conn irc.Conn)
- func (h *Helper) CollectFromChannel(ch <-chan *irc.Message) *[]*irc.Message
- func (h *Helper) CollectFromConn(conn irc.Decoder) *[]*irc.Message
- func (h *Helper) CollectSentToServer() *[]*irc.Message
- func (h *Helper) Dial() irc.Conn
- func (h *Helper) SendAsServer(ctx context.Context, m *irc.Message)
- func (h *Helper) SendAsServerErr(ctx context.Context, m *irc.Message) error
- func (h *Helper) SendWithConn(conn irc.Encoder, m *irc.Message)
- func (h *Helper) ServerMessages() <-chan *irc.Message
- func (h *Helper) Sleep()
- func (h *Helper) StopServer()
- func (h *Helper) StopServerErr() (err error)
- func (h *Helper) Wait()
- type Option
- type Server
Constants ¶
const ChannelTag = "test-channel"
ChannelTag is a tag key which can be used to direct messages at specific channels.
Variables ¶
var ErrStopped = errors.New("fakeirc: server is stopped")
ErrStopped is returned by Server.Send if the server has been stopped.
var TLSConfig = &tls.Config{ InsecureSkipVerify: true, ClientAuth: tls.RequireAndVerifyClientCert, Certificates: []tls.Certificate{testCert}, PreferServerCipherSuites: true, ClientCAs: certPool, RootCAs: certPool, } // #nosec G402
TLSConfig is a TLS configuration that can be used for testing. The fake IRC server will use this config to authenticate incoming connections when using TLS.
Functions ¶
Types ¶
type Helper ¶
Helper wraps the fake IRC server, providing convenience methods for managing messages.
func (*Helper) AssertMessages ¶
AssertMessages asserts that the given messages match the expected messages.
func (*Helper) CollectFromChannel ¶
CollectFromChannel collects all messages sent to the provided channel, asynchronously, returning a pointer to a slice which will contain the messages.
func (*Helper) CollectFromConn ¶
CollectFromConn collects all messages sent to a conn, asynchronously, returning a pointer to a slice which will contain the messages.
func (*Helper) CollectSentToServer ¶
CollectSentToServer collects all messages sent to the server, asynchronously, returning a pointer to a slice which will contain the messages.
func (*Helper) SendAsServer ¶
SendAsServer sends a message as the server, asserting that the send was successful.
func (*Helper) SendAsServerErr ¶
SendAsServerErr sends a message to the server, and returns the send error.
func (*Helper) SendWithConn ¶
SendWithConn sends a message via an IRC conn, asserts its success, and sleeps.
func (*Helper) ServerMessages ¶
ServerMessages returns the channel of messages sent to the server.
func (*Helper) StopServerErr ¶
StopServerErr stops the fake IRC server, returning the stop error.
type Option ¶
type Option func(s *Server)
Option configures the server.
func RecordPings ¶
RecordPings enables recording of incoming pings the incoming channel.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a fake IRC server for use in testing.
func (*Server) Incoming ¶
Incoming returns the channel of messages being sent to the server from clients.