testutil

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package testutil provides testing helpers, mock beans, and test application container utilities for the Helix framework.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBean

func GetBean[T any](app *App) T

GetBean resolves a component from the test app container and fails the test immediately if resolution is impossible.

Types

type App

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

App is a Helix application container scoped to a Go test.

func NewApp

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

NewApp creates, configures, starts, and registers cleanup for a test app.

func (*App) Close

func (a *App) Close() error

Close shuts down the test app once.

func (*App) Config

func (a *App) Config() config.Loader

Config returns the configuration loader used by the test app.

func (*App) Container

func (a *App) Container() *core.Container

Container returns the underlying Helix DI container.

type Option

type Option func(*appOptions)

Option configures a Helix test application.

func MockBean

func MockBean[T any](impl T) Option

MockBean replaces components assignable to T with impl in a Helix test app.

func WithComponents

func WithComponents(components ...any) Option

WithComponents registers components in the test container before startup.

func WithConfigDefaults

func WithConfigDefaults(values map[string]any) Option

WithConfigDefaults configures fallback values for the test config loader.

func WithConfigPaths

func WithConfigPaths(paths ...string) Option

WithConfigPaths overrides directories searched for application test config.

func WithContainerOptions

func WithContainerOptions(containerOptions ...core.Option) Option

WithContainerOptions appends core container options to the test container.

Jump to

Keyboard shortcuts

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