emailtest

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package emailtest provides a mock implementation of gas.EmailProvider for use in tests. The mock records all calls and allows configuring per-method behavior via function fields.

mock := &emailtest.MockEmail{}
mock.SendFn = func(ctx context.Context, msg *gas.Email) error {
    return nil
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

type Call struct {
	Method string
	Args   []any
}

Call records a single method invocation on the mock.

type MockEmail

type MockEmail struct {
	SendFn             func(ctx context.Context, msg *gas.Email) error
	SendFromTemplateFn func(ctx context.Context, msg *gas.TemplatedEmail) error
	CheckReadyFn       func(ctx context.Context) error
	Calls              []Call
	// contains filtered or unexported fields
}

MockEmail is a configurable mock of gas.EmailProvider. Each method delegates to its corresponding Fn field if set, otherwise returns the zero value. All calls are recorded in the Calls slice for assertions.

func (*MockEmail) CallCount

func (m *MockEmail) CallCount(method string) int

CallCount returns the number of times the given method was called.

func (*MockEmail) CheckReady

func (m *MockEmail) CheckReady(ctx context.Context) error

CheckReady records the call and delegates to CheckReadyFn if set.

func (*MockEmail) Reset

func (m *MockEmail) Reset()

Reset clears all recorded calls.

func (*MockEmail) Send

func (m *MockEmail) Send(ctx context.Context, msg *gas.Email) error

Send records the call and delegates to SendFn if set.

func (*MockEmail) SendFromTemplate

func (m *MockEmail) SendFromTemplate(ctx context.Context, msg *gas.TemplatedEmail) error

SendFromTemplate records the call and delegates to SendFromTemplateFn if set.

Jump to

Keyboard shortcuts

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