Documentation ¶
Overview ¶
Package tests provides the framework for integration testing of maddy.
The packages core object is tests.T object that encapsulates all test state. It runs the server using test-provided configuration file and acts as a proxy for all interactions with the server.
Index ¶
- Variables
- type Conn
- func (c *Conn) AllowIOErr(ok bool)
- func (c *Conn) Close() error
- func (c *Conn) Expect(line string) error
- func (c *Conn) ExpectPattern(pat string) string
- func (c *Conn) Readln() (string, error)
- func (c *Conn) Rebind(subtest *T) *Conn
- func (c *Conn) SMTPNegotation(ourName string, requireExts, blacklistExts []string)
- func (c *Conn) TLS()
- func (c *Conn) Write(s string)
- func (c *Conn) Writeln(s string)
- type T
- func (t *T) Close()
- func (t *T) Config(cfg string)
- func (t *T) Conn(portName string) Conn
- func (t *T) Conn4(sourceIP, portName string) Conn
- func (t *T) Conn6(portName string) Conn
- func (t *T) DNS(zones map[string]mockdns.Zone)
- func (t *T) Port(name string) uint16
- func (t *T) Printf(f string, a ...interface{})
- func (t *T) Run(waitListeners int)
- func (t *T) RuntimeDir() string
- func (t *T) StateDir() string
- func (t *T) Subtest(name string, f func(t *T))
Constants ¶
This section is empty.
Variables ¶
var ( TestBinary = "./maddy" CoverageOut string DebugLog bool )
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn struct { T *T WriteTimeout time.Duration ReadTimeout time.Duration Conn net.Conn Scanner *bufio.Scanner // contains filtered or unexported fields }
Conn is a helper that simplifies testing of text protocol interactions.
func (*Conn) AllowIOErr ¶
AllowIOErr toggles whether I/O errors should be returned to the caller of Conn method or should immedately fail the test.
By default (ok = false), the latter happens.
func (*Conn) ExpectPattern ¶
ExpectPattern reads a line from the connection socket and checks whether is matches the supplied shell pattern (as defined by path.Match). The original line is returned.
func (*Conn) SMTPNegotation ¶
type T ¶
func (*T) Config ¶
Config sets the configuration to use for the server. It must be called before Run.
func (*T) Conn4 ¶
Conn4 connects to the server listener at the specified named port using one of 127.0.0.0/8 addresses as a source.
func (*T) Conn6 ¶
Conn6 connects to the server listener at the specified named port using IPv6 loopback.
func (*T) DNS ¶
DNS sets the DNS zones to emulate for the tested server instance.
If it is not called before Run, DNS(nil) call is assumed which makes the mockdns server respond with NXDOMAIN to all queries.
func (*T) Port ¶
Port allocates the random TCP port for use by test. It will made accessible in the configuration via environment variables with name in the form TEST_PORT_name.
If there is a port with name remote_smtp, it will be passed as the value for the -debug.smtpport parameter.
func (*T) Run ¶
Run completes the configuration of test environment and starts the test server.
T.Close should be called by the end of test to release any resources and shutdown the server.
The parameter waitListeners specifies the amount of listeners the server is supposed to configure. Run() will block before all of them are up.