mock

package
v0.4.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package mock provides intermediary data structures to assist in testing and debugging sending an email without actually sending the email - testing the creation and sending of email typically requires some kind of tracking of what was sent or not and metadata about the message which is what is setup here

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckEmails

func CheckEmails(t *testing.T, messages []*EmailMetadata)

CheckEmails verifies that the provided email messages exist on the mock. This method should only be called from a test context and checks to make sure that the given emails were "sent" (not actually sent hehe)

func ResetEmailMock

func ResetEmailMock()

ResetEmailMock tests that send emails should call ResetEmailMock as part of their cleanup to ensure that other tests can depend on the state of the mock

Types

type EmailLog

type EmailLog struct {
	sync.Mutex
	Data [][]byte
}

EmailLog combines email data with a mutex to ensure that tests can safely access the mock concurrently for that email blastertons

var Emails EmailLog

Emails contains all emails sent by the mock which tests can use to verify which emails were sent

type EmailMetadata

type EmailMetadata struct {
	To          string
	From        string
	Subject     string
	Timestamp   time.Time
	Attachments int
}

EmailMetadata makes it easier for tests to verify that the correct emails were sent without comparing the entire email body since that's 'spensive

type SendGridClient

type SendGridClient struct {
	Storage string
}

SendGridClient is the duct tape method which allows for local storage output

func (*SendGridClient) Send

func (c *SendGridClient) Send(msg *sgmail.SGMailV3) (rep *rest.Response, err error)

Send is responsible for sending an email using the SendGrid API

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL