Documentation
¶
Index ¶
- func Call(ctx context.Context, fn Func, args ...any) (any, error)
- func MustCall(t tb, fn Func, args ...any) any
- type Author
- type Func
- type FuncSpec
- type FunctionInfo
- type Invocation
- type Plugin
- type PluginInfo
- type PluginWithFuncs
- type Registry
- type SpecList
- type SpecProvider
- type Spy
- type TestRegistry
- func (r *TestRegistry) AddPlugin(info plugins.PluginInfo, providers []plugins.SpecProvider)
- func (r *TestRegistry) Funcs() map[string]any
- func (r *TestRegistry) Groups(ctx context.Context) []plugins.PluginWithFuncs
- func (r *TestRegistry) Hooks(group string) []plugins.Func
- func (r *TestRegistry) Plugins(ctx context.Context) []plugins.PluginInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Func ¶
Re-exports public plugin API for tests.
func Decorate ¶
Decorate wraps base with decorator while preserving the canonical signature. In tests this is useful to assert decoration order or to inject spies.
func LookupFunc ¶
LookupFunc fetches a Func from a Registry by name for assertion or invocation without reaching into registry internals.
func MustLookupFunc ¶
MustLookupFunc fetches a function by name or fails the test immediately, avoiding repetitive error handling in plugin specs tests.
type FunctionInfo ¶
type FunctionInfo = plugins.FunctionInfo
Re-exports public plugin API for tests.
type Invocation ¶
Invocation captures a single call to a spied function, including arguments and results, so tests can assert call order and data.
type Plugin ¶
Re-exports public plugin API for tests.
func NewPlugin ¶
func NewPlugin(info PluginInfo, providers ...SpecProvider) Plugin
NewPlugin forwards to plugins.NewPlugin for fixtures that prefer the full Plugin object instead of raw registry calls.
type PluginWithFuncs ¶
type PluginWithFuncs = plugins.PluginWithFuncs
Re-exports public plugin API for tests.
type SpecProvider ¶
type SpecProvider = plugins.SpecProvider
Re-exports public plugin API for tests.
func Specs ¶
func Specs(specs ...FuncSpec) SpecProvider
Specs forwards to plugins.Specs so tests can stay within plugintest imports.
type Spy ¶
type Spy struct {
Calls []Invocation
// contains filtered or unexported fields
}
Spy records calls to a wrapped plugin Func without altering behavior, enabling verification of decorators or dynamic template helpers.
func (*Spy) Decorator ¶
Decorator returns a decorator that records calls to the base function, convenient for testing decorator chaining.
type TestRegistry ¶
type TestRegistry struct {
// contains filtered or unexported fields
}
TestRegistry is a lightweight, in-memory Registry implementation dedicated to tests. It mirrors the public contract yet stays free of production-only behavior (sources, trust), letting tests register and look up plugin functions deterministically.
func NewRegistry ¶
func NewRegistry() *TestRegistry
NewRegistry creates an empty TestRegistry with no preloaded plugins.
func NewRegistryWith ¶
func NewRegistryWith(info plugins.PluginInfo, providers ...plugins.SpecProvider) *TestRegistry
NewRegistryWith creates a registry and immediately registers provided plugins, a convenience to keep tests concise.
func (*TestRegistry) AddPlugin ¶
func (r *TestRegistry) AddPlugin(info plugins.PluginInfo, providers []plugins.SpecProvider)
AddPlugin registers plugin specs without applying production priorities. The latest registration for a name wins unless a decorator chains onto an existing function.
func (*TestRegistry) Funcs ¶
func (r *TestRegistry) Funcs() map[string]any
Funcs implements Registry.Funcs and returns a copy safe for mutation in tests.
func (*TestRegistry) Groups ¶
func (r *TestRegistry) Groups(ctx context.Context) []plugins.PluginWithFuncs
Groups returns plugin info alongside functions to support info-oriented tests.
func (*TestRegistry) Hooks ¶
func (r *TestRegistry) Hooks(group string) []plugins.Func
Hooks returns functions filtered by Group.
func (*TestRegistry) Plugins ¶
func (r *TestRegistry) Plugins(ctx context.Context) []plugins.PluginInfo
Plugins returns shallow-copied plugin metadata for assertions.