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 MustCreateActor(t *testing.T, ctx context.Context, s store.Interface, actor *ateapipb.Actor) *ateapipb.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 *ateapipb.Tag) *ateapipb.Tag
- func RunTests(m *testing.M)
- func SetupPostgresPersistence(t *testing.T) *atepg.Persistence
- func SetupTestStore(t *testing.T) (store.Interface, func())
- func Shutdown()
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 ¶
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 ¶
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.