Documentation
¶
Overview ¶
Package memsender provides an omnimail.Sender that captures messages in memory. It is intended for tests: assert on what an application sent without a mail server, and inject failures to exercise error handling.
s := memsender.New()
app := NewApp(s)
app.SignUp(ctx, "user@example.org")
if s.Len() != 1 || !strings.Contains(s.Last().Text, "/verify?") { ... }
Index ¶
- Constants
- type Sender
- func (s *Sender) FailNext(err error)
- func (s *Sender) Last() *omnimail.Message
- func (s *Sender) Len() int
- func (s *Sender) Messages() []*omnimail.Message
- func (s *Sender) Reset()
- func (s *Sender) Results() []omnimail.SendResult
- func (s *Sender) Send(ctx context.Context, msg *omnimail.Message) (*omnimail.SendResult, error)
- func (s *Sender) SetFailFunc(fn func(*omnimail.Message) error)
Constants ¶
View Source
const ProviderName = "memory"
ProviderName is reported in SendResult.Provider.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Sender ¶
type Sender struct {
// contains filtered or unexported fields
}
Sender captures messages in memory. It is safe for concurrent use. The zero value is ready to use.
func (*Sender) FailNext ¶
FailNext queues err to be returned by the next valid Send. Each queued error is used once, in order.
func (*Sender) Reset ¶
func (s *Sender) Reset()
Reset discards captured messages, queued failures and the fail function.
func (*Sender) Results ¶
func (s *Sender) Results() []omnimail.SendResult
Results returns the SendResults in send order.
Click to show internal directories.
Click to hide internal directories.