sorotest

package
v0.0.0-...-d364ca2 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: Apache-2.0 Imports: 17 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.

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 migrations and before the HTTP server starts. Applications normally register resources, custom routes, hooks, and job handlers here.

func WithMigrations

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

WithMigrations applies migrations before the test app is returned.

type Response

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

func (*Response) Decode

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

Jump to

Keyboard shortcuts

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