Documentation
¶
Overview ¶
Package testkit provides lightweight test helpers for chassis-go services. It has zero dependencies on other chassis packages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetFreePort ¶
GetFreePort asks the OS for an available TCP port by listening on :0, then closes the listener and returns the assigned port. This is useful for parallel tests that each need their own listener.
func NewLogger ¶
NewLogger returns a *slog.Logger that writes JSON output to t.Log so that log lines appear alongside test output and are suppressed on success unless -v is passed. The level is set to Debug so every message is captured.
func SetEnv ¶
SetEnv sets the supplied environment variables and registers a t.Cleanup to unset them after the test. This is the building block for test config — pair it with config.MustLoad[T]() in your test to load typed configuration.
Example:
testkit.SetEnv(t, map[string]string{"PORT": "8080"})
cfg := config.MustLoad[AppConfig]()
Types ¶
This section is empty.