Documentation
¶
Overview ¶
Package testkit provides a canonical harness for module-level tests.
Index ¶
- func Controller[T any](tb TB, h *Harness, moduleName, controllerName string) T
- func ControllerE[T any](h *Harness, moduleName, controllerName string) (T, error)
- func Get[T any](tb TB, h *Harness, token module.Token) T
- func GetE[T any](h *Harness, token module.Token) (T, error)
- type ControllerNotFoundError
- type Harness
- type HarnessCloseError
- type NilOptionError
- type Option
- type Override
- type TB
- type TypeAssertionError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Controller ¶
Controller returns a typed controller or fails the test.
func ControllerE ¶
ControllerE returns a typed controller instance.
Types ¶
type ControllerNotFoundError ¶
ControllerNotFoundError is returned when a controller key is missing in the harness app.
func (*ControllerNotFoundError) Error ¶
func (e *ControllerNotFoundError) Error() string
type Harness ¶
type Harness struct {
// contains filtered or unexported fields
}
Harness wraps a bootstrapped app for test ergonomics.
type HarnessCloseError ¶
HarnessCloseError aggregates cleanup hook and app close errors.
func (*HarnessCloseError) Error ¶
func (e *HarnessCloseError) Error() string
func (*HarnessCloseError) Unwrap ¶
func (e *HarnessCloseError) Unwrap() []error
Unwrap returns both hook and close errors for errors.Is/errors.As matching.
type NilOptionError ¶
type NilOptionError struct {
Index int
}
NilOptionError is returned when a nil testkit option is passed.
func (*NilOptionError) Error ¶
func (e *NilOptionError) Error() string
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option configures testkit harness construction.
func WithOverrides ¶
WithOverrides applies provider overrides for harness bootstrap.
func WithoutAutoClose ¶
func WithoutAutoClose() Option
WithoutAutoClose disables automatic tb.Cleanup registration.
type Override ¶
type Override struct {
Token module.Token
Build func(module.Resolver) (any, error)
Cleanup func(context.Context) error
}
Override describes a token-level provider override for tests.
func OverrideBuild ¶
OverrideBuild returns a dynamic build override.
type TypeAssertionError ¶
TypeAssertionError is returned when a typed helper cannot assert the requested type.
func (*TypeAssertionError) Error ¶
func (e *TypeAssertionError) Error() string