storetest

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 20 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 storetest provides isolated PostgreSQL-backed stores for tests.

One PostgreSQL container is shared by every test in a package; each test gets its own database. Nothing stops that container when the test binary exits, so packages using this package must call Shutdown from their TestMain.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultSystemPrincipals

func DefaultSystemPrincipals() authz.SystemPrincipals

DefaultSystemPrincipals returns valid SystemPrincipals for tests that initialize authz.New without testing system component roles.

func MustCreateActor

func MustCreateActor(t *testing.T, ctx context.Context, s store.Interface, actor *ateapi.Actor) *ateapi.Actor

MustCreateActor ensures actor's parent atespace exists, then creates actor. Use the store method directly only in tests that exercise missing-parent behavior.

func MustCreateAtespace

func MustCreateAtespace(t *testing.T, ctx context.Context, s store.Interface, name string)

MustCreateAtespace creates name unless it already exists. PostgreSQL enforces the parent relationship for actor and snapshot records, so test fixtures use this before seeding those resources.

func MustCreateTag

func MustCreateTag(t *testing.T, ctx context.Context, s store.Interface, tag *ateapi.Tag) *ateapi.Tag

MustCreateTag ensures tag's parent atespace exists, then stores tag as given — ready or still pending, whichever state the test needs to start from. Use the store method directly only in tests that exercise missing-parent behavior.

func MustSeedAssignment added in v1.0.0

func MustSeedAssignment(t *testing.T, ctx context.Context, s store.Interface, workerName string, assignment *ateapi.ActorAssignment)

MustSeedAssignment books assignment on workerName as BindActorToWorker does, stamping its metadata the same way, but without the Actor update BindActorToWorker commits with it. Tests use it to seed an Actor already placed, or a Worker's bookings with no Actor stored behind them. s must come from SetupPostgresPersistence or SetupTestStore.

func RunTests

func RunTests(m *testing.M)

RunTests runs m and terminates the shared PostgreSQL container afterwards. Packages with no other TestMain work should use it as their whole TestMain; the rest must call Shutdown themselves.

func SetupPostgresPersistence

func SetupPostgresPersistence(t *testing.T) *atepg.Persistence

SetupPostgresPersistence returns an isolated atepg persistence instance.

func SetupTestStore

func SetupTestStore(t *testing.T) (store.Interface, func())

SetupTestStore returns a real PostgreSQL-backed store with a database unique to this test. A shared container keeps this suitable for packages that run subtests in parallel; databases are dropped during cleanup.

func Shutdown

func Shutdown()

Shutdown terminates the shared PostgreSQL container, if one was started.

func WorkerHostingActor added in v1.0.0

func WorkerHostingActor(t *testing.T, ctx context.Context, s store.Interface, actorUID string) string

WorkerHostingActor returns the name of the Worker holding an assignment for actorUID, or "" when none does.

Types

This section is empty.

Jump to

Keyboard shortcuts

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