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 ¶
- func DefaultSystemPrincipals() authz.SystemPrincipals
- func MustCreateActor(t *testing.T, ctx context.Context, s store.Interface, actor *ateapi.Actor) *ateapi.Actor
- func MustCreateAtespace(t *testing.T, ctx context.Context, s store.Interface, name string)
- func MustCreateTag(t *testing.T, ctx context.Context, s store.Interface, tag *ateapi.Tag) *ateapi.Tag
- func MustSeedAssignment(t *testing.T, ctx context.Context, s store.Interface, workerName string, ...)
- func RunTests(m *testing.M)
- func SetupPostgresPersistence(t *testing.T) *atepg.Persistence
- func SetupTestStore(t *testing.T) (store.Interface, func())
- func Shutdown()
- func WorkerHostingActor(t *testing.T, ctx context.Context, s store.Interface, actorUID string) string
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 ¶
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 ¶
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 ¶
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.
Types ¶
This section is empty.