test

package
v0.4.5 Latest Latest
Warning

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

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

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package test provides shared integration-test helpers for go-llm packages.

The harness in this package creates a disposable PostgreSQL container, bootstraps the minimal auth schema required by llmmanager, resolves provider-specific environment variables, exposes a go-pg/pkg/test-style Main/Conn lifecycle, and provides common helpers for runtime loops, bounded contexts, synthetic auth users, and provider/model setup.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdminUser

func AdminUser(conn *Conn) *auth.User

AdminUser returns a synthetic user with the configured provider groups.

func ConnectorURL

func ConnectorURL(t *testing.T, name string) string

ConnectorURL creates a live in-process MCP server and returns its base URL.

func Context

func Context(t *testing.T) context.Context

Context returns a bounded context suitable for integration tests.

func CreateProvider

func CreateProvider(
	t *testing.T,
	insert schema.ProviderInsert,
	create func(context.Context, schema.ProviderInsert) (*schema.Provider, error),
	sync func(context.Context) ([]string, []string, error),
) *schema.Provider

CreateProvider persists and syncs a provider for an integration test.

func DiscardLogger

func DiscardLogger() *slog.Logger

DiscardLogger returns a logger that drops all output.

func IsUnreachable

func IsUnreachable(err error) bool

IsUnreachable reports transport-level connectivity failures for live-provider integration tests.

func Main

func Main(m *testing.M, conn *Conn, config ProviderConfig)

func ModelName

func ModelName(
	t *testing.T,
	preferred string,
	list func(context.Context) (*schema.ModelList, error),
) string

ModelName returns the preferred model when available, otherwise the first model advertised by the provider.

func ModelNameMatching

func ModelNameMatching(
	t *testing.T,
	preferred string,
	list func(context.Context) (*schema.ModelList, error),
	match func(schema.Model) bool,
	validate func(context.Context, string) error,
) string

ModelNameMatching returns the first model that matches the predicate and, when provided, passes validation. The preferred model is tried first.

func RunBackground

func RunBackground(t *testing.T, run func(context.Context) error)

RunBackground runs a cancelable integration-test loop and waits for it to exit during test cleanup.

func User

func User(conn *Conn, groups ...string) *auth.User

User creates a synthetic auth user and optional group memberships.

func WaitUntil

func WaitUntil(t *testing.T, duration time.Duration, condition func() bool, message string)

WaitUntil polls until the condition becomes true or the timeout elapses.

Types

type Conn

type Conn struct {
	pg.PoolConn
	Config          ProviderConfig
	SetupSkipReason string
	SkipReason      string
	// contains filtered or unexported fields
}

func (*Conn) Begin

func (c *Conn) Begin(t *testing.T) *Conn

func (*Conn) Close

func (c *Conn) Close()

func (*Conn) ProviderInsert

func (c *Conn) ProviderInsert() schema.ProviderInsert

func (*Conn) RequireProvider

func (c *Conn) RequireProvider(t *testing.T)

type ProviderConfig

type ProviderConfig struct {
	Name     string
	Provider string
	Model    string
	URL      string
	APIKey   string
	Groups   []string
}

Jump to

Keyboard shortcuts

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