{"modulePath":"github.com/foxcpp/maddy","version":"v0.9.8","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package testutils\n\n## Constants\n\n```go\nconst (\n\tMessageBodySize             = 100 * 1024\n\tExtraMessageHeaderFields    = 10\n\tExtraMessageHeaderFieldSize = 50\n)\n```\nEmpirically observed \"around average\" values.\n\n```go\nconst DeliveryData = \"A: 1\\r\\n\" +\n\t\"B: 2\\r\\n\" +\n\t\"\\r\\n\" +\n\t\"foobar\\r\\n\"\n```\n\n## Functions\n\n```go\nfunc BenchDelivery(b *testing.B, target module.DeliveryTarget, sender string, recipientTemplates []string)\n```\n\n```go\nfunc BodyFromStr(t *testing.T, literal string) (textproto.Header, buffer.MemoryBuffer)\n```\n\n```go\nfunc CheckMsg(t *testing.T, msg *Msg, sender string, rcpt []string)\n```\n\n```go\nfunc CheckMsgID(t *testing.T, msg *Msg, sender string, rcpt []string, id string) string\n```\n\n```go\nfunc CheckSMTPConnLeak(t *testing.T, srv *smtp.Server)\n```\n\n```go\nfunc CheckSMTPErr(t *testing.T, err error, code int, enchCode exterrors.EnhancedCode, msg string)\n```\n\n```go\nfunc CheckTestMessage(t *testing.T, tgt *Target, indx int, sender string, rcpt []string)\n```\n\n```go\nfunc Dir(t *testing.T) string\n```\nDir is a wrapper for os.MkdirTemp that fails the test on errors.\n\n```go\nfunc DoTestDelivery(t *testing.T, tgt module.DeliveryTarget, from string, to []string) string\n```\n\n```go\nfunc DoTestDeliveryErr(t *testing.T, tgt module.DeliveryTarget, from string, to []string) (string, error)\n```\n\n```go\nfunc DoTestDeliveryErrMeta(t *testing.T, tgt module.DeliveryTarget, from string, to []string, msgMeta *module.MsgMetadata) (string, error)\n```\n\n```go\nfunc DoTestDeliveryMeta(t *testing.T, tgt module.DeliveryTarget, from string, to []string, msgMeta *module.MsgMetadata) string\n```\n\n```go\nfunc DoTestDeliveryNonAtomic(t *testing.T, c module.StatusCollector, tgt module.DeliveryTarget, from string, to []string) string\n```\n\n```go\nfunc EffectiveSMTPServerPort(t *testing.T, s *smtp.Server) uint16\n```\n\n```go\nfunc FailOnConn(t *testing.T, addr string) net.Listener\n```\nFailOnConn fails the test if attempt is made to connect the specified endpoint.\n\n```go\nfunc Logger(t *testing.T, name string) *log.Logger\n```\n\n```go\nfunc RandomMsg(b *testing.B) (module.MsgMetadata, textproto.Header, buffer.Buffer)\n```\n\n```go\nfunc WaitForConnsClose(t *testing.T, srv *smtp.Server)\n```\n\n## Types\n\n```go\ntype Check struct {\n\tInitErr   error\n\tEarlyErr  error\n\tConnRes   module.CheckResult\n\tSenderRes module.CheckResult\n\tRcptRes   module.CheckResult\n\tBodyRes   module.CheckResult\n\n\tConnCalls   int\n\tSenderCalls int\n\tRcptCalls   int\n\tBodyCalls   int\n\n\tUnclosedStates int\n\n\tInstName string\n}\n```\n\n```go\nfunc (c *Check) CheckConnection(ctx context.Context, state *module.ConnState) error\n```\n\n```go\nfunc (c *Check) CheckStateForMsg(ctx context.Context, msgMeta *module.MsgMetadata) (module.CheckState, error)\n```\n\n```go\nfunc (c *Check) Configure([]string, *config.Map) error\n```\n\n```go\nfunc (c *Check) InstanceName() string\n```\n\n```go\nfunc (c *Check) Name() string\n```\n\n```go\ntype FailingBuffer struct {\n\tBlob []byte\n\n\tOpenError error\n\tIOError   error\n}\n```\n\n```go\nfunc (fb FailingBuffer) Len() int\n```\n\n```go\nfunc (fb FailingBuffer) Open() (io.ReadCloser, error)\n```\n\n```go\nfunc (fb FailingBuffer) Remove() error\n```\n\n```go\ntype Modifier struct {\n\tInstName string\n\n\tInitErr     error\n\tMailFromErr error\n\tRcptToErr   error\n\tBodyErr     error\n\n\tMailFrom map[string]string\n\tRcptTo   map[string][]string\n\tAddHdr   textproto.Header\n\n\tUnclosedStates int\n}\n```\n\n```go\nfunc (m Modifier) Configure([]string, *config.Map) error\n```\n\n```go\nfunc (m Modifier) InstanceName() string\n```\n\n```go\nfunc (m Modifier) ModStateForMsg(ctx context.Context, msgMeta *module.MsgMetadata) (module.ModifierState, error)\n```\n\n```go\nfunc (m Modifier) Name() string\n```\n\n```go\ntype Msg struct {\n\tMsgMeta  *module.MsgMetadata\n\tMailFrom string\n\tRcptTo   []string\n\tBody     []byte\n\tHeader   textproto.Header\n}\n```\n\n```go\ntype MultiTable struct {\n\tM   map[string][]string\n\tErr error\n}\n```\n\n```go\nfunc (m MultiTable) Lookup(_ context.Context, a string) (string, bool, error)\n```\n\n```go\nfunc (m MultiTable) LookupMulti(_ context.Context, a string) ([]string, error)\n```\n\n```go\ntype SMTPBackend struct {\n\tMessages        []*SMTPMessage\n\tMailFromCounter int\n\tSessionCounter  int\n\tSourceEndpoints map[string]struct{}\n\n\tAuthErr     error\n\tMailErr     error\n\tRcptErr     map[string]error\n\tDataErr     error\n\tLMTPDataErr []error\n\n\tActiveSessionsCounter atomic.Int32\n}\n```\n\n```go\nfunc SMTPServer(t *testing.T, addr string, fn ...SMTPServerConfigureFunc) (*SMTPBackend, *smtp.Server)\n```\n\n```go\nfunc SMTPServerSTARTTLS(t *testing.T, addr string, fn ...SMTPServerConfigureFunc) (*tls.Config, *SMTPBackend, *smtp.Server)\n```\nSMTPServerSTARTTLS starts a server listening on the specified addr with the STARTTLS extension supported.\n\nReturned \\*tls.Config is for the client and is set to trust the server certificate.\n\n```go\nfunc SMTPServerTLS(t *testing.T, addr string, fn ...SMTPServerConfigureFunc) (*tls.Config, *SMTPBackend, *smtp.Server)\n```\nSMTPServerTLS starts a SMTP server listening on the specified addr with Implicit TLS.\n\n```go\nfunc (be *SMTPBackend) CheckMsg(t *testing.T, indx int, from string, rcptTo []string) *SMTPMessage\n```\n\n```go\nfunc (be *SMTPBackend) ConnectionCount() int\n```\n\n```go\nfunc (be *SMTPBackend) Msg(t *testing.T, indx int) *SMTPMessage\n```\n\n```go\nfunc (be *SMTPBackend) NewSession(conn *smtp.Conn) (smtp.Session, error)\n```\n\n```go\ntype SMTPMessage struct {\n\tFrom     string\n\tOpts     smtp.MailOptions\n\tTo       []string\n\tData     []byte\n\tConn     *smtp.Conn\n\tAuthUser string\n\tAuthPass string\n\tTLS      *tls.ConnectionState\n}\n```\n\n```go\ntype SMTPServerConfigureFunc func(*smtp.Server)\n```\n\n```go\ntype Table struct {\n\tM   map[string]string\n\tErr error\n}\n```\n\n```go\nfunc (m Table) Lookup(_ context.Context, a string) (string, bool, error)\n```\n\n```go\ntype Target struct {\n\tMessages        []Msg\n\tDiscardMessages bool\n\n\tStartErr       error\n\tRcptErr        map[string]error\n\tBodyErr        error\n\tPartialBodyErr map[string]error\n\tAbortErr       error\n\tCommitErr      error\n\n\tInstName string\n}\n```\n\n```go\nfunc (dt *Target) Configure([]string, *config.Map) error\n```\n\n```go\nfunc (dt *Target) InstanceName() string\n```\n\n```go\nfunc (dt *Target) Name() string\n```\n\n```go\nfunc (dt *Target) StartDelivery(ctx context.Context, msgMeta *module.MsgMetadata, mailFrom string) (module.Delivery, error)\n```\n\n","path":"github.com/foxcpp/maddy/internal/testutils","name":"testutils","synopsis":"","isRedistributable":true}
