Documentation
¶
Overview ¶
Package backendtest is the protocol backend contract (ADR 0037): one suite every backend.Receiver runs, against a fixture that starts the backend and puts mail on, or injects faults into, its server.
Index ¶
- func Message(id, subject string) []byte
- func Run(t *testing.T, start Fixture)
- func RunOnly(t *testing.T, start Fixture, names ...string)
- func RunSender(t *testing.T, start SendFixture)
- type Delivery
- type Fake
- func (s *Fake) Deliver(_ *testing.T, name string, raw []byte)
- func (s *Fake) Messages(name string) map[backend.MessageRef]backend.Flags
- func (s *Fake) Receiver(t *testing.T) backend.Receiver
- func (s *Fake) RejectAuth(*testing.T)
- func (s *Fake) Remove(name string, r backend.MessageRef)
- func (s *Fake) Reset(_ *testing.T, name string)
- func (s *Fake) SetFlags(name string, r backend.MessageRef, fl backend.Flags)
- type Fixture
- type SendFixture
- type SendServer
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunOnly ¶
RunOnly runs only the named parts of the contract, for a backend whose other verbs are still to come.
func RunSender ¶
func RunSender(t *testing.T, start SendFixture)
RunSender runs the sending part of the contract against the backend start gives.
Types ¶
type Delivery ¶
type Delivery struct {
Rcpts []string // the addresses it goes to
Raw []byte // as the server got it; a backend may add header fields
}
Delivery is one message a sending server accepted.
type Fake ¶ added in v1.37.0
type Fake struct {
// OnSync, when set, runs each Sync in place of the fake's own: it hands
// commit the pages a test wants stored. It runs without the fake's lock.
OnSync func(req backend.SyncRequest, commit func(backend.Page) error) (more bool, err error)
// OnApply, when set, answers each Apply: apply is the fake's own Apply
// (the server doing op), which it may call or not, and whose answer it may
// replace (an Unlocated move, a refusal, a lost reply). It runs without the
// fake's lock.
OnApply func(op backend.Op, apply func() (backend.Result, error)) (backend.Result, error)
// contains filtered or unexported fields
}
Fake is a minimal in-memory Server that passes the contract: one folder per name, locations "epoch/n", a folder cursor "epoch/last", IdentityLocation. Tests of local storage script it through OnSync and OnApply.
func (*Fake) Messages ¶ added in v1.37.0
Messages is the folder named name as the server has it: each location's flags.
func (*Fake) RejectAuth ¶ added in v1.37.0
type SendFixture ¶
type SendFixture func(t *testing.T) SendServer
SendFixture starts a SendServer for one test.
type SendServer ¶
type SendServer interface {
// Sender starts a new sending backend on the account.
Sender(t *testing.T) backend.Sender
// Accepted is every message the server has accepted, in order.
Accepted(t *testing.T) []Delivery
// Refuse makes the server refuse, for good, every message to rcpt.
Refuse(t *testing.T, rcpt string)
// LoseVerdict makes the server take the whole next message and then drop
// the connection without answering.
LoseVerdict(t *testing.T)
// RejectAuth makes the server refuse the account's credentials from now on.
RejectAuth(t *testing.T)
}
SendServer is one fresh account on a fixture's sending server.
type Server ¶
type Server interface {
// Receiver starts a new backend on the account, closed when t ends.
Receiver(t *testing.T) backend.Receiver
// Deliver puts raw into the folder named folder, creating it if need be,
// as mail arriving. "INBOX" is the inbox.
Deliver(t *testing.T, folder string, raw []byte)
// Reset makes the server void every location in the folder named folder:
// IMAP's UIDVALIDITY changes, JMAP cannot calculate changes. A fixture
// that cannot calls t.Skip.
Reset(t *testing.T, folder string)
// RejectAuth makes the server refuse the account's credentials from now on.
RejectAuth(t *testing.T)
}
Server is one fresh account on a fixture's server.