conformance

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 12 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 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

func Run

func Run(t *testing.T, s Subject)

Run runs the suite on s.

Types

type Kind

type Kind int

Kind is the kind of queue a rule asks for.

const (
	// Standard is a standard queue.
	Standard Kind = iota
	// FIFO is a FIFO queue without content-based deduplication.
	FIFO
	// FIFOContentDedupe is a FIFO queue with content-based deduplication.
	FIFOContentDedupe
)

The kinds of queue.

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.

Jump to

Keyboard shortcuts

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