Documentation
¶
Overview ¶
Package mailtest is an in-memory mail.Mailbox for tests of the packages that sit on top of the connector. It keeps the same promises as the IMAP one: UIDs only grow, a moved message gets a new UID in its destination, fetching never sets \Seen, and a reference with the wrong UIDVALIDITY finds nothing.
Index ¶
- type Mailbox
- func (m *Mailbox) AddFolder(name, role string)
- func (m *Mailbox) Append(ctx context.Context, name string, raw []byte, flags []string, date time.Time) (mail.MsgRef, error)
- func (m *Mailbox) Capabilities() mail.Caps
- func (m *Mailbox) Close() error
- func (m *Mailbox) Delete(ctx context.Context, ref mail.MsgRef) error
- func (m *Mailbox) Deliver(folderName, eml string, flags ...string) mail.MsgRef
- func (m *Mailbox) EnsureFolder(ctx context.Context, name string) error
- func (m *Mailbox) Fetch(ctx context.Context, ref mail.MsgRef, maxBody int) (*message.Raw, error)
- func (m *Mailbox) FetchMany(ctx context.Context, refs []mail.MsgRef, maxBody int) ([]*message.Raw, error)
- func (m *Mailbox) FetchSince(ctx context.Context, name string, since time.Time, limit int) ([]mail.MsgRef, int, error)
- func (m *Mailbox) FindByMessageID(ctx context.Context, name, messageID string) (mail.MsgRef, error)
- func (m *Mailbox) Flags(ctx context.Context, ref mail.MsgRef) ([]string, error)
- func (m *Mailbox) Folders(ctx context.Context) ([]mail.Folder, error)
- func (m *Mailbox) Message(ref mail.MsgRef) (raw string, flags []string, err error)
- func (m *Mailbox) Move(ctx context.Context, ref mail.MsgRef, dest string) (mail.MsgRef, error)
- func (m *Mailbox) MoveMany(ctx context.Context, refs []mail.MsgRef, dest string) ([]mail.MsgRef, error)
- func (m *Mailbox) Present(ctx context.Context, name string, uidValidity uint32, uids []uint32) ([]uint32, error)
- func (m *Mailbox) SentRecipients(ctx context.Context, name string, limit int) ([]mail.Recipient, error)
- func (m *Mailbox) SetFlags(ctx context.Context, ref mail.MsgRef, add, remove []string) error
- func (m *Mailbox) Status(ctx context.Context, name string) (mail.FolderStatus, error)
- func (m *Mailbox) Watch(ctx context.Context, name string, lastUID uint32, out chan<- mail.NewMail) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Mailbox ¶
type Mailbox struct {
AccountID int64
Caps mail.Caps
// Moves counts move commands, one per Move and one per MoveMany, so a test can tell a
// batch from a run of single moves. Read it while nothing else uses the mailbox.
Moves int
// contains filtered or unexported fields
}
Mailbox is the fake. Set Caps before use to simulate a limited server.
func (*Mailbox) AddFolder ¶
AddFolder creates a folder with a special-use role ("" for none). Re-adding an existing name rebuilds it empty with a new UIDVALIDITY.
func (*Mailbox) Append ¶ added in v0.3.0
func (m *Mailbox) Append(ctx context.Context, name string, raw []byte, flags []string, date time.Time) (mail.MsgRef, error)
Append adds a message to a folder, as APPEND does, and returns its place as APPENDUID would, without waking watchers of new mail (a draft is not an arrival).
func (*Mailbox) Capabilities ¶
Capabilities returns Caps.
func (*Mailbox) Delete ¶ added in v0.3.0
Delete removes one message for good; without UIDPLUS it refuses, as the IMAP connector does.
func (*Mailbox) Deliver ¶
Deliver puts an RFC 5322 message into a folder, as new mail arriving, and wakes watchers.
func (*Mailbox) EnsureFolder ¶
EnsureFolder creates the folder if it is missing.
func (*Mailbox) Fetch ¶
Fetch returns a copy of the message with its text cut to maxBody bytes. Flags are untouched.
func (*Mailbox) FetchMany ¶
func (m *Mailbox) FetchMany(ctx context.Context, refs []mail.MsgRef, maxBody int) ([]*message.Raw, error)
FetchMany returns a copy of each message, like Fetch, and nil for one that is gone.
func (*Mailbox) FetchSince ¶
func (m *Mailbox) FetchSince(ctx context.Context, name string, since time.Time, limit int) ([]mail.MsgRef, int, error)
FetchSince lists messages delivered at or after since, oldest first, newest limit only.
func (*Mailbox) FindByMessageID ¶
FindByMessageID returns the newest message in the folder with that Message-ID.
func (*Mailbox) Message ¶ added in v0.3.0
Message returns the whole stored message at ref, header and text, and its flags: for tests that check what was appended.
func (*Mailbox) MoveMany ¶ added in v0.3.0
func (m *Mailbox) MoveMany(ctx context.Context, refs []mail.MsgRef, dest string) ([]mail.MsgRef, error)
MoveMany is Move for each message, as one command, with a zero MsgRef for one that is not there.
func (*Mailbox) Present ¶ added in v0.3.0
func (m *Mailbox) Present(ctx context.Context, name string, uidValidity uint32, uids []uint32) ([]uint32, error)
Present reports which of uids the folder still holds; a message marked \Deleted is gone.
func (*Mailbox) SentRecipients ¶
func (m *Mailbox) SentRecipients(ctx context.Context, name string, limit int) ([]mail.Recipient, error)
SentRecipients returns the To and Cc addresses of the newest limit messages.