Documentation
¶
Overview ¶
Package testutil provides lightweight helpers for writing tests in agentwatch. It is internal — do not promote to a public package without a concrete consumer need.
Index ¶
- func DiscardLogger() *slog.Logger
- func LoadFixture(t testing.TB, name string) []byte
- func NewLogger(t testing.TB) (*slog.Logger, *bytes.Buffer)
- func RequireEqual[T comparable](t testing.TB, want, got T)
- func RequireNoError(t testing.TB, err error)
- func TempDir(t testing.TB) string
- func WriteFixture(t testing.TB, dir, name string, data []byte) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DiscardLogger ¶
DiscardLogger returns an *slog.Logger that silently discards all output. Use it when a logger is required but log output is irrelevant to the test.
func LoadFixture ¶
LoadFixture reads testdata/<name> relative to the calling test's working directory (the package directory). The test fails if the file cannot be read.
func NewLogger ¶
NewLogger returns an *slog.Logger and a *bytes.Buffer that captures its output at Debug level and above. Use buf.String() in assertions to verify that specific messages were logged.
func RequireEqual ¶
func RequireEqual[T comparable](t testing.TB, want, got T)
RequireEqual fails t immediately if want != got.
func RequireNoError ¶
RequireNoError fails t immediately if err is non-nil.
Types ¶
This section is empty.