{"modulePath":"github.com/foxcpp/maddy","version":"v0.9.8","isLatest":true,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package tests\n\nPackage tests provides the framework for integration testing of maddy.\n\nThe 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.\n\n## Variables\n\n```go\nvar (\n\tTestBinary  = \"./maddy\"\n\tCoverageOut string\n\tDebugLog    bool\n\tNoFDSharing bool\n)\n```\n\n```go\nvar (\n\tDefaultSourceIP    = net.IPv4(127, 109, 97, 100)\n\tDefaultSourceIPRev = \"100.97.109.127\"\n)\n```\n\n## Functions\n\n```go\nfunc RandomPort() uint16\n```\n\n## Types\n\n```go\ntype Conn struct {\n\tT *T\n\n\tWriteTimeout time.Duration\n\tReadTimeout  time.Duration\n\n\tConn    net.Conn\n\tScanner *bufio.Scanner\n\t// contains filtered or unexported fields\n}\n```\nConn is a helper that simplifies testing of text protocol interactions.\n\n```go\nfunc (c *Conn) AllowIOErr(ok bool)\n```\nAllowIOErr toggles whether I/O errors should be returned to the caller of Conn method or should immedately fail the test.\n\nBy default (ok = false), the latter happens.\n\n```go\nfunc (c *Conn) Close() error\n```\n\n```go\nfunc (c *Conn) Expect(line string)\n```\n\n```go\nfunc (c *Conn) ExpectPattern(pat string) string\n```\nExpectPattern 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.\n\n```go\nfunc (c *Conn) MustClose()\n```\n\n```go\nfunc (c *Conn) Readln() (string, error)\n```\n\n```go\nfunc (c *Conn) Rebind(subtest *T) *Conn\n```\n\n```go\nfunc (c *Conn) SMTPNegotation(ourName string, requireExts, blacklistExts []string)\n```\n\n```go\nfunc (c *Conn) SMTPPlainAuth(username, password string, expectOk bool)\n```\n\n```go\nfunc (c *Conn) TLS()\n```\n\n```go\nfunc (c *Conn) Write(s string)\n```\nWrite writes the string to the connection socket.\n\n```go\nfunc (c *Conn) Writeln(s string)\n```\n\n```go\ntype T struct {\n\t*testing.T\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewT(t *testing.T) *T\n```\n\n```go\nfunc (t *T) AllowFDSharing()\n```\nAllowFDSharing enables the use of Unix FD sharing for Port to ensure the selected port number is usable without races.\n\nIt must be called at least once before Port is used to enable FD sharing.\n\n```go\nfunc (t *T) Close()\n```\n\n```go\nfunc (t *T) Config(cfg string)\n```\nConfig sets the configuration to use for the server. It must be called before Run.\n\n```go\nfunc (t *T) Conn(portName string) Conn\n```\n\n```go\nfunc (t *T) Conn4(sourceIP, portName string) Conn\n```\nConn4 connects to the server listener at the specified named port using one of 127.0.0.0/8 addresses as a source.\n\n```go\nfunc (t *T) Conn6(portName string) Conn\n```\nConn6 connects to the server listener at the specified named port using IPv6 loopback.\n\n```go\nfunc (t *T) ConnUnnamed(port uint16) Conn\n```\n\n```go\nfunc (t *T) DNS(zones map[string]mockdns.Zone)\n```\nDNS sets the DNS zones to emulate for the tested server instance.\n\nIf it is not called before Run, DNS(nil) call is assumed which makes the mockdns server respond with NXDOMAIN to all queries.\n\n```go\nfunc (t *T) Env(kv string)\n```\n\n```go\nfunc (t *T) MustRunCLI(args ...string) string\n```\n\n```go\nfunc (t *T) MustRunCLIGroup(args ...[]string)\n```\n\n```go\nfunc (t *T) Port(name string) uint16\n```\nPort 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.\n\nIf there is a port with name remote\\_smtp, it will be passed as the value for the -debug.smtpport parameter.\n\n```go\nfunc (t *T) Printf(f string, a ...any)\n```\nPrintf implements Logger interfaces used by some libraries.\n\n```go\nfunc (t *T) RemoteSMTPPort(port uint16) uint16\n```\nRemoteSMTPPort defines a special port named remote\\_smtp. It does not use FD sharing and will be passed to -debug.smtpport.\n\nIf passed value is 0, the port is randomly generated though this is not recommended - instead you should start a receiver using 0 port first and pass effective port to this method.\n\n```go\nfunc (t *T) Run(waitListeners int)\n```\nRun completes the configuration of test environment and starts the test server.\n\nT.Close should be called by the end of test to release any resources and shutdown the server.\n\nThe parameter waitListeners specifies the amount of listeners the server is supposed to configure. Run() will block before all of them are up.\n\n```go\nfunc (t *T) RunCLI(args ...string) (string, error)\n```\n\n```go\nfunc (t *T) RuntimeDir() string\n```\n\n```go\nfunc (t *T) StateDir() string\n```\n\n```go\nfunc (t *T) Subtest(name string, f func(t *T))\n```\n\n","path":"github.com/foxcpp/maddy/tests","name":"tests","synopsis":"Package tests provides the framework for integration testing of maddy.","isRedistributable":true}
