Documentation
¶
Overview ¶
Package mock is for mocking the sending of emails, for testing and such
Index ¶
- type EmailSender
- func (s *EmailSender) Messages() []*newman.EmailMessage
- func (s *EmailSender) Reset()
- func (s *EmailSender) SendBatchEmail(messages []*newman.EmailMessage) error
- func (s *EmailSender) SendBatchEmailWithContext(ctx context.Context, messages []*newman.EmailMessage) error
- func (s *EmailSender) SendEmail(message *newman.EmailMessage) error
- func (s *EmailSender) SendEmailWithContext(_ context.Context, message *newman.EmailMessage) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EmailSender ¶ added in v0.4.0
type EmailSender struct {
// contains filtered or unexported fields
}
EmailSender is a mock email sender that captures sent messages for test assertion. It satisfies newman.EmailSender and additionally exposes Reset and Messages for inspecting what was sent
func New ¶
func New(storage string) (*EmailSender, error)
New creates a mock email sender. If storage is non-empty, sent emails are also written to disk as MIME files for manual inspection
func (*EmailSender) Messages ¶ added in v0.4.0
func (s *EmailSender) Messages() []*newman.EmailMessage
Messages returns a snapshot of all captured messages
func (*EmailSender) Reset ¶ added in v0.4.0
func (s *EmailSender) Reset()
Reset clears captured messages. Tests that send emails should call Reset as part of cleanup so other tests start with a clean slate
func (*EmailSender) SendBatchEmail ¶ added in v0.4.0
func (s *EmailSender) SendBatchEmail(messages []*newman.EmailMessage) error
SendBatchEmail sends a batch of emails with the given messages
func (*EmailSender) SendBatchEmailWithContext ¶ added in v0.4.0
func (s *EmailSender) SendBatchEmailWithContext(ctx context.Context, messages []*newman.EmailMessage) error
SendBatchEmailWithContext validates and captures each message in the batch
func (*EmailSender) SendEmail ¶ added in v0.4.0
func (s *EmailSender) SendEmail(message *newman.EmailMessage) error
SendEmail sends an email with the given message
func (*EmailSender) SendEmailWithContext ¶ added in v0.4.0
func (s *EmailSender) SendEmailWithContext(_ context.Context, message *newman.EmailMessage) error
SendEmailWithContext validates and captures the message for later assertion