testhelpers

package
v1.3.33 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFakeAuthProvider

func NewFakeAuthProvider(user auth.Identifiable, err error) auth.Provider

func NewInMemoryBus

func NewInMemoryBus() *event.InMemoryBus

NewInMemoryBus returns a ready-to-use in-memory event bus for tests.

func NewMemoryTempDriver

func NewMemoryTempDriver(t *testing.T) (*memory.Driver, func())

NewMemoryTempDriver creates a memory storage driver backed by a temporary directory.

func NewTestRegistry

func NewTestRegistry(t *testing.T, models ...any) (*database.Registry, func())

NewTestRegistry returns an in-memory sqlite *gorm.DB and a cleanup function for tests.

func PublishSync

func PublishSync(ctx context.Context, b event.Bus, ev any) error

PublishSync publishes an event and waits for handlers to complete. This is a small helper that simply calls bus.Publish and returns its result.

func WriteString

func WriteString(t *testing.T, d *memory.Driver, key, content string)

WriteString writes content to the driver at key. Useful for test setup.

Types

type FakeAuthProvider

type FakeAuthProvider struct {
	User auth.Identifiable
	Err  error
}

FakeAuthProvider is a simple AuthProvider that returns a preset user or error.

func (*FakeAuthProvider) Verify

func (f *FakeAuthProvider) Verify(ctx context.Context, token string) (auth.Identifiable, error)

type TestUser

type TestUser struct {
	ID   int
	Name string
}

TestUser is a trivial Identifiable for tests.

func (TestUser) GetID

func (u TestUser) GetID() int

Jump to

Keyboard shortcuts

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