Documentation
¶
Overview ¶
Package sendtest drives campaign sends end to end in tests: the real API's data, the sending engine on a virtual clock and the demo transport whose delivery and engagement events go through the same normalization as provider webhooks. Reports, Send Readiness and the live monitor are tested on what production writes, not on demo rows (review F-5).
Index ¶
- Constants
- Variables
- type ContactSpec
- type FaultState
- func (f *FaultState) Calls() int
- func (f *FaultState) Release()
- func (f *FaultState) Reset(mode string)
- func (f *FaultState) SetIPs(ips ...string)
- func (f *FaultState) SetMode(mode string)
- func (f *FaultState) Started() <-chan struct{}
- func (f *FaultState) Took() map[uuid.UUID]int
- func (f *FaultState) TookFor(address string) int
- type Fixture
- func (f *Fixture) AddContacts(specs ...ContactSpec)
- func (f *Fixture) Count(sql string, args ...any) int64
- func (f *Fixture) Counts() map[string]int64
- func (f *Fixture) Drive(d time.Duration) (time.Time, bool)
- func (f *Fixture) DriveWithout(d time.Duration, kinds ...string) (time.Time, bool)
- func (f *Fixture) Dump()
- func (f *Fixture) Exec(sql string, args ...any)
- func (f *Fixture) HandedOver(specs ...ContactSpec) []uuid.UUID
- func (f *Fixture) ProviderID(adapter string) uuid.UUID
- func (f *Fixture) StartSend(o engine.StartOptions)
- func (f *Fixture) Status() string
- func (f *Fixture) UseFaultProvider(dedupe bool) uuid.UUID
- func (f *Fixture) UseFaultSMTP() uuid.UUID
- func (f *Fixture) UseReportingProvider() uuid.UUID
- type Suite
Constants ¶
const ( // FaultOK takes every message and answers. FaultOK = "ok" // FaultTakeNoAnswer takes the messages, then never answers: the call // ends with the engine's call timeout. FaultTakeNoAnswer = "take_no_answer" // FaultHold takes the messages once the test closes Release, then // answers; Started is signalled when a call arrives. FaultHold = "hold" // FaultRefuse refuses the call with a 503 the provider answered. FaultRefuse = "refuse" // FaultFlaky refuses every other call with a 503 and takes the rest. FaultFlaky = "flaky" // FaultThrottle answers 429: the account sends too fast. FaultThrottle = "throttle" // FaultQuota answers that the account's daily quota is used up. FaultQuota = "quota" // FaultIdentity refuses every message: the sender isn't verified. FaultIdentity = "identity" )
Fault modes.
Variables ¶
var Fault = &FaultState{}
Fault is the fault providers' shared state.
Functions ¶
This section is empty.
Types ¶
type ContactSpec ¶
type ContactSpec struct {
N int
Mailbox string
Domain string
Tier string
Source string
Engaged bool
Status string
Suppress bool
Paused bool
Role bool
// Alias makes the batch plus-tagged aliases of the fixture's first
// contacts (same domain): the same mailboxes.
Alias bool
// RolePattern gives the batch role addresses (info+…@) without the flag.
RolePattern bool
// Stopped: the sunset policy stopped their Broadcasts.
Stopped bool
// StoppedPair adds, for each contact (Stopped), a newer active alias.
StoppedPair bool
// Unclassified leaves the mailbox provider to the classifier, which
// looks the domain's MX record up when the send starts; otherwise
// Mailbox is final.
Unclassified bool
}
ContactSpec describes a batch of test contacts.
type FaultState ¶
type FaultState struct {
// contains filtered or unexported fields
}
FaultState is what the fault providers do and what they took.
func (*FaultState) Release ¶
func (f *FaultState) Release()
Release lets the calls held in FaultHold go.
func (*FaultState) Reset ¶
func (f *FaultState) Reset(mode string)
Reset sets the mode and forgets what was taken.
func (*FaultState) SetIPs ¶
func (f *FaultState) SetIPs(ips ...string)
SetIPs sets the dedicated IPs faultesp-ips lists; none is a shared pool.
func (*FaultState) SetMode ¶
func (f *FaultState) SetMode(mode string)
SetMode changes what the providers do, keeping what they took.
func (*FaultState) Started ¶
func (f *FaultState) Started() <-chan struct{}
Started is signalled when a call arrives in FaultHold.
func (*FaultState) Took ¶
func (f *FaultState) Took() map[uuid.UUID]int
Took is how many times the provider took each message (a delivery).
func (*FaultState) TookFor ¶
func (f *FaultState) TookFor(address string) int
TookFor is how many messages the provider took for an address.
type Fixture ¶
Fixture is one scenario: a copy of Weekly Digest #142 (content, sender, A/B test) sending to a list of the scenario's own contacts.
func (*Fixture) AddContacts ¶
func (f *Fixture) AddContacts(specs ...ContactSpec)
AddContacts inserts contacts in the fixture's list.
func (*Fixture) Counts ¶
Counts are the fixture's campaign counters, summed over its cells, by column name (sent, delivered, opened_human…).
func (*Fixture) Drive ¶
Drive runs the send for d of virtual time from the fixture's start and returns where it stopped and whether the send ended.
func (*Fixture) DriveWithout ¶
DriveWithout is Drive with what the demo transport plans of these kinds (delivered, deferred, hard_bounce, soft_bounce, complaint, open, click; every kind with none) dropped before any of it comes due, so the test scripts those outcomes itself. Like Drive, it steps the engine once a second, sending and then applying the events due by then; but it drives each second only for a moment, since a send that ends applies the events due by the end of its drive. An event comes due 0.6 s after its message went out at the earliest, so what a step's sends planned is dropped before anything can apply it.
func (*Fixture) HandedOver ¶
func (f *Fixture) HandedOver(specs ...ContactSpec) []uuid.UUID
HandedOver sends the fixture's campaign to its contacts (without the A/B test) until every message is with a provider, and drops what the demo transport plans for them before any of it comes due (a chance bounce or complaint would suppress the address), so a test scripts their deliveries, opens and clicks itself. It returns the messages in id order.
func (*Fixture) ProviderID ¶
ProviderID is the workspace's connected provider of an adapter.
func (*Fixture) StartSend ¶
func (f *Fixture) StartSend(o engine.StartOptions)
StartSend starts the send now and builds its audience.
func (*Fixture) UseFaultProvider ¶
UseFaultProvider connects a fault provider to the workspace and sends the fixture's campaign through it alone. It returns the provider's id.
func (*Fixture) UseFaultSMTP ¶
UseFaultSMTP is UseFaultProvider with a provider that reports no deliveries, as plain SMTP doesn't.
func (*Fixture) UseReportingProvider ¶
UseReportingProvider is UseFaultProvider with a provider whose API lists the account's dedicated IPs (Fault.SetIPs), on the shared pool until someone asks it.
type Suite ¶
type Suite struct {
Env *apptest.Env
E *engine.Engine
Ctx context.Context
WS uuid.UUID
Sofia uuid.UUID
Start time.Time
// contains filtered or unexported fields
}
Suite is one seeded demo shared by a test's scenarios, with the sending engine on a virtual clock that starts at Start.