testdoubles

package
v0.0.0-...-25a6cea Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressValidator

type AddressValidator struct {
	Email   string
	Failure *email.ValidationFailure
	Error   error
}

func NewAddressValidator

func NewAddressValidator() *AddressValidator

func (*AddressValidator) AssertValidated

func (av *AddressValidator) AssertValidated(
	t *testing.T, expectedEmail string,
)

func (*AddressValidator) ValidateAddress

func (av *AddressValidator) ValidateAddress(
	ctx context.Context, email string,
) (*email.ValidationFailure, error)

type Database

type Database struct {
	Subscribers         []*db.Subscriber
	SimulateGetErr      func(emailAddress string) error
	SimulatePutErr      func(emailAddress string) error
	SimulateDelErr      func(emailAddress string) error
	SimulateCountErr    func(emailAddress string) error
	SimulateProcSubsErr func(emailAddress string) error
	Index               map[string]*db.Subscriber
}

func NewDatabase

func NewDatabase() *Database

func (*Database) CountSubscribers

func (dbase *Database) CountSubscribers(
	ctx context.Context, status db.SubscriberStatus,
) (count int64, err error)

func (*Database) Delete

func (dbase *Database) Delete(_ context.Context, email string) error

func (*Database) Get

func (dbase *Database) Get(
	_ context.Context, email string,
) (sub *db.Subscriber, err error)

func (*Database) ProcessSubscribers

func (dbase *Database) ProcessSubscribers(
	_ context.Context, status db.SubscriberStatus, sp db.SubscriberProcessor,
) error

func (*Database) Put

func (dbase *Database) Put(_ context.Context, sub *db.Subscriber) error

type Mailer

type Mailer struct {
	RecipientMessages map[string][]byte
	MessageIds        map[string]string
	RecipientErrors   map[string]error
	BulkCapError      error
}

func NewMailer

func NewMailer() *Mailer

func (*Mailer) AssertNoMessageSent

func (m *Mailer) AssertNoMessageSent(t *testing.T, recipient string)

func (*Mailer) BulkCapacityAvailable

func (mailer *Mailer) BulkCapacityAvailable(_ context.Context) error

func (*Mailer) GetMessageTo

func (m *Mailer) GetMessageTo(
	t *testing.T, recipient string,
) (msgId, msg string)

func (*Mailer) Send

func (m *Mailer) Send(
	ctx context.Context, recipient string, msg []byte,
) (messageId string, err error)

type Suppressor

type Suppressor struct {
	Addresses map[string]ops.RemoveReason
	Errors    map[string]error
}

func NewSuppressor

func NewSuppressor() *Suppressor

func (*Suppressor) IsSuppressed

func (s *Suppressor) IsSuppressed(
	ctx context.Context, address string,
) (ok bool, err error)

func (*Suppressor) Suppress

func (s *Suppressor) Suppress(
	ctx context.Context, address string, reason ops.RemoveReason) error

func (*Suppressor) Unsuppress

func (s *Suppressor) Unsuppress(ctx context.Context, address string) error

Jump to

Keyboard shortcuts

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