storetest

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

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 MustCreateActor

func MustCreateActor(t *testing.T, ctx context.Context, s store.Interface, actor *ateapipb.Actor) *ateapipb.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 *ateapipb.Tag) *ateapipb.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 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.

Types

This section is empty.

Jump to

Keyboard shortcuts

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