sorotest

package
v0.0.0-...-51ec7a6 Latest Latest
Warning

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

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

Documentation

Overview

Package sorotest provides schema-isolated Soro application test helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFactory

func NewFactory[T any](app *App, builder factory.Builder[T], options ...repository.OperationOption) (*factory.Factory[T], error)

NewFactory binds a typed factory to the test app's repository for T.

func OpenRuntimeDatabase

func OpenRuntimeDatabase(t testing.TB, maxConns int32, setup RuntimeSetup) *database.DB

OpenRuntimeDatabase opens an isolated database through the configured non-owner runtime role. It is intended for application RLS integration tests.

Types

type App

type App struct {
	*soro.App
	// contains filtered or unexported fields
}

func New

func New(t testing.TB, options ...Option) *App

New boots a test-environment application in an isolated PostgreSQL schema. It skips the test when SORO_TEST_DATABASE_URL is not configured.

func (*App) Client

func (app *App) Client() *Client

func (*App) Messages

func (app *App) Messages() []*mail.Message

func (*App) ResetMail

func (app *App) ResetMail()

type Client

type Client struct {
	// contains filtered or unexported fields
}

func (*Client) HTTP

func (client *Client) HTTP() *http.Client

func (*Client) Request

func (client *Client) Request(ctx context.Context, method, path string, input any) (*Response, error)

Request sends a request to the in-process Soro application. Input is encoded as JSON when non-nil. Paths must be local absolute paths such as /api/v1/users.

func (*Client) URL

func (client *Client) URL(path string) (string, error)

type Option

type Option func(*settings) error

func Configure

func Configure(configure func(*config.Config)) Option

Configure mutates the test configuration before validation and app startup.

func Setup

func Setup(callback func(*soro.App) error) Option

Setup runs after explicit migrations and before the HTTP server starts. Applications normally register resources, custom routes, hooks, and job handlers here; engines have already mounted before this callback runs.

func WithEngines

func WithEngines(engines ...engine.Engine) Option

WithEngines explicitly mounts engines before migrations, setup, and HTTP. Declared engine migrations are applied by New; application migrations remain explicit through WithMigrations, and mounting an engine never applies SQL.

func WithMigrations

func WithMigrations(migrations ...migrate.Migration) Option

WithMigrations contributes explicit application migrations before the test app is returned. Engine-owned declarations are included in the same plan.

type Response

type Response struct {
	StatusCode int
	Header     http.Header
	Body       []byte
}

func (*Response) Decode

func (response *Response) Decode(destination any) error

type RuntimeSetup

type RuntimeSetup func(context.Context, *pgx.Conn, string, string) error

RuntimeSetup provisions an isolated schema before the constrained runtime role connects. Use it to apply application migrations and grants as an owner.

Jump to

Keyboard shortcuts

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