Documentation
¶
Overview ¶
Package emailmock provides mock implementations of the email package's interfaces. Both the hand-written testify-based Emailer type and the moq-generated EmailerMock type live here during the testify → moq migration. New test code should prefer the moq-generated types.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EmailerMock ¶
type EmailerMock struct {
// SendEmailFunc mocks the SendEmail method.
SendEmailFunc func(ctx context.Context, details *email.OutboundEmailMessage) error
// contains filtered or unexported fields
}
EmailerMock is a mock implementation of email.Emailer.
func TestSomethingThatUsesEmailer(t *testing.T) {
// make and configure a mocked email.Emailer
mockedEmailer := &EmailerMock{
SendEmailFunc: func(ctx context.Context, details *email.OutboundEmailMessage) error {
panic("mock out the SendEmail method")
},
}
// use mockedEmailer in code that requires email.Emailer
// and then make assertions.
}
func (*EmailerMock) SendEmail ¶
func (mock *EmailerMock) SendEmail(ctx context.Context, details *email.OutboundEmailMessage) error
SendEmail calls SendEmailFunc.
func (*EmailerMock) SendEmailCalls ¶
func (mock *EmailerMock) SendEmailCalls() []struct { Ctx context.Context Details *email.OutboundEmailMessage }
SendEmailCalls gets all the calls that were made to SendEmail. Check the length with:
len(mockedEmailer.SendEmailCalls())
Click to show internal directories.
Click to hide internal directories.