Documentation
¶
Overview ¶
Package testutil provides utility functions and types for testing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetFreeTCPPort ¶ added in v0.1.0
GetFreeTCPPort asks the kernel for a free open port that is ready to use.
Types ¶
type Base ¶ added in v0.1.0
type Base struct {
Logger *slog.Logger
Dependencies map[string]Dependency
CacheDir string
// contains filtered or unexported fields
}
Base is a utility struct that provides common resources and utilities for testing.
func (*Base) ForController ¶ added in v0.1.0
func (b *Base) ForController() *ControllerBase
ForController creates a new instance of ControllerBase with a Base.
func (*Base) GetFreeTCPPort ¶ added in v0.1.0
GetFreeTCPPort returns a free TCP port that is ready to use.
type Controller ¶
type Controller interface {
RoutesInfo() gin.RoutesInfo
}
Controller is an interface that defines the methods for a controller.
type ControllerBase ¶
ControllerBase is a struct that provides a base for controllers.
func (*ControllerBase) SetupRouter ¶
func (b *ControllerBase) SetupRouter(controller Controller)
SetupRouter sets up the router for the controller.
type Dependency ¶ added in v0.1.0
type Dependency interface {
Name() string
Configure(config any)
Start()
Stop()
Info() map[string]string
}
Dependency is an interface that represents a dependency in the test environment.
type TestLogWriter ¶ added in v0.1.26
TestLogWriter is an io.Writer that writes to the test log. This is useful for capturing logs in tests, especially when working with libraries that write to io.Writer (e.g., slog.TextHandler).