testpb

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HookBinder

type HookBinder func(app *tests.TestApp) error

HookBinder allows callers to register app hooks before serving routes.

type Option

type Option func(*startOptions)

Option configures Start.

func WithDataDir

func WithDataDir(dir string) Option

WithDataDir overrides the PocketBase test data directory.

func WithHookBinder

func WithHookBinder(binder HookBinder) Option

WithHookBinder registers a callback invoked after app initialization and before serving.

type Server

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

Server wraps an embedded PocketBase test app and HTTP server.

func Start

func Start(t testing.TB, opts ...Option) *Server

Start boots an embedded PocketBase test server.

func (*Server) ClientForRecord

func (s *Server) ClientForRecord(t testing.TB, collection, email string) pbclient.AuthenticatedClient

ClientForRecord builds a token client for a collection record.

The returned client honors pbclient.WithContentType and pbclient.WithHeader on each Do call. pbclient.WithAuthStaleStatuses is a documented no-op because the adapter has no token-refresh lifecycle (the token is fixed for the life of the client).

func (*Server) ClientWithToken

func (s *Server) ClientWithToken(token string) pbclient.AuthenticatedClient

ClientWithToken returns a pbclient.AuthenticatedClient backed by the embedded server.

The returned client honors pbclient.WithContentType and pbclient.WithHeader on each Do call. pbclient.WithAuthStaleStatuses is a documented no-op because the adapter has no token-refresh lifecycle (the token is fixed for the life of the client).

func (*Server) Close

func (s *Server) Close()

Close shuts down the test server and cleans app state.

func (*Server) SuperuserClient

func (s *Server) SuperuserClient(t testing.TB, email string) pbclient.AuthenticatedClient

SuperuserClient builds a token client for a superuser email.

The returned client honors pbclient.WithContentType and pbclient.WithHeader on each Do call. pbclient.WithAuthStaleStatuses is a documented no-op because the adapter has no token-refresh lifecycle (the token is fixed for the life of the client).

func (*Server) Token

func (s *Server) Token(t testing.TB, collection, email string) string

Token generates an auth token for a record identified by collection + email.

Jump to

Keyboard shortcuts

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