backendtest

package
v0.331.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: MIT Imports: 10 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 backendtest is the officer-backend conformance suite (officer-backend/v1, docs/design/officers-first-class.md): the lease, queue, tier and refusal rules every officers.Backend must keep, as named checks over a small World. It runs against HQ's client over the hqtest fake and against the built-in backend over Postgres, and each harness carries a fault-injection knob that lets a second claim through a live lease — run with it on, the double-claim check must fail, so the suite is shown able to go red against each backend, not only green.

Index

Constants

View Source
const (
	OfficerA = "triage:conformance-a"
	OfficerB = "triage:conformance-b"
)

The two officers every World declares, each with its own items. Both are owned by user 1.

View Source
const CheckDoubleClaim = "a live lease refuses another instance's claim"

CheckDoubleClaim is the check a double-claim fault must fail.

Variables

This section is empty.

Functions

func Run

func Run(t *testing.T, newWorld func(t *testing.T) World)

Run runs every check against a fresh World from newWorld.

Types

type Check

type Check struct {
	Name string
	Run  func(ctx context.Context, w World) error
}

Check is one conformance rule.

func Checks

func Checks() []Check

Checks is the suite.

func Find

func Find(name string) Check

Find is the check named name (the fault tests run one check on purpose).

type World

type World interface {
	// Backend is the backend of OfficerA or OfficerB.
	Backend(officer string) officers.Backend
	// AddItem adds an open, unblocked item and returns its id. tier is
	// routine or judgement; priority "" is normal.
	AddItem(officer, kind, subject, tier, priority string) officers.ItemID
	// SetBlocked marks item id blocked (by some unfinished task).
	SetBlocked(id officers.ItemID)
	// SetEnabled turns officer's switch on or off.
	SetEnabled(officer string, on bool)
	// SetCharter sets officer's charter (its type's).
	SetCharter(officer, charter string)
	// Advance moves the backend's clock forward by d.
	Advance(d time.Duration)
}

World is one backend implementation under test, freshly seeded with the two officers, no items, both enabled.

Jump to

Keyboard shortcuts

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