authtest

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package authtest holds test helpers for applications that use the framework's auth: a Mailer that records the account lifecycle's messages instead of sending them, so a test can read the token a flow mailed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mailer

type Mailer struct {

	// Err, when set, is returned by Send, and the message is not recorded.
	Err error
	// contains filtered or unexported fields
}

Mailer is an auth.Mailer that records every message, for tests. Set Err to make Send fail. It is safe for concurrent use.

mail := &authtest.Mailer{}
app, _ := framework.New(framework.WithAuthMailer(mail), ...)
// register ada@example.com, then:
token := mail.Last("ada@example.com").Token

func (*Mailer) Last

func (m *Mailer) Last(address string) (auth.Message, bool)

Last returns the latest message sent to address, and whether there is one.

func (*Mailer) Messages

func (m *Mailer) Messages() []auth.Message

Messages returns the recorded messages, oldest first.

func (*Mailer) Reset

func (m *Mailer) Reset()

Reset forgets the recorded messages.

func (*Mailer) Send

func (m *Mailer) Send(_ context.Context, msg auth.Message) error

Send records msg, or returns Err.

Jump to

Keyboard shortcuts

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