Documentation
¶
Overview ¶
Package conformance holds the tests every store of the module runs: the contract of the queue package, checked with identical expectations against a store built by the caller.
Usage ¶
A store's tests call Run with a Subject that builds a new, uninitialized store with the VisibilityTimeout setting the suite asks for, and creates the queues the suite asks for:
conformance.Run(t, conformance.Subject{
Name: memory.ServiceName,
New: func(t *testing.T, visibility time.Duration) conformance.Store {
cfg := memory.DefaultConfig()
cfg.Queue.VisibilityTimeout = visibility
s, err := memory.New(memory.WithConfig(cfg))(nil, &gas.NopLogger{})
require.NoError(t, err)
return s
},
CreateQueue: createQueue,
})
A store whose server the tests share gives each queue a name of its own. Subject.Skip names the rules a store skips, each with the reason, such as an emulator that does not do as SQS does.
Suite ¶
Run runs each rule as a parallel subtest, on a new store each: a round trip with the attributes Dequeue reports, Nack, NackAfter, Extend, the end of a visibility timeout, delays, short and long polls, maxMessages, an ended context before and during a call, a queue that does not exist, identifiers that are not queues, the payload, size and attribute rules, a long attribute name, the bounds of a delay, FIFO order, groups and rules, deduplication by ID and by content, a group ID on a standard queue, the bounds of Dequeue's arguments and of a visibility timeout, receipt handles, a second Ack, the lifecycle sentinels and a restart, Init with an ended context, Close ending a waiting Dequeue, concurrent calls for -race, and errors that never quote a message. Every error is checked with errors.Is, and its full text where it is the same for every store; the text starts with the Subject's Name.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Store ¶
type Store interface {
gas.Service
gas.JobQueueProvider
// NackAfter makes the job's message visible after d.
NackAfter(ctx context.Context, queue string, job gas.Job, d time.Duration) error
// Extend keeps the job's message hidden for d more.
Extend(ctx context.Context, queue string, job gas.Job, d time.Duration) error
}
Store is a queue store with a lifecycle and the visibility calls every store of the module has.
type Subject ¶
type Subject struct {
// New returns a new store, not initialized, whose VisibilityTimeout
// setting is visibility.
New func(t *testing.T, visibility time.Duration) Store
// CreateQueue creates a new queue of kind, with no other message and
// a visibility timeout of 30s, for st, which is initialized, and
// returns its identifier.
CreateQueue func(t *testing.T, st Store, kind Kind) string
// Skip maps the name of a rule to the reason the subject skips it,
// such as an emulator that does not do as SQS does.
Skip map[string]string
// Name is the store's ServiceName, which starts its errors.
Name string
}
Subject is a store under test.