testutil

package
v0.0.0-...-5934ca9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErectRequest

func ErectRequest(t testing.TB, opts ...any) *http.Request

func ErectResponse

func ErectResponse(t testing.TB, opts ...any) *http.Response

func JSON

func JSON(t testing.TB, res *http.Response, pairs ...any)

func LogLogger

func LogLogger(t TestLogger) *log.Logger

LogLogger returns a logger that logs to t.

func Logger

func Logger(t TestLogger) *slog.Logger

Logger returns a logger that logs to t at slog.DebugLevel in text format without times and levels.

Types

type MaybeLogger

type MaybeLogger struct {
	// contains filtered or unexported fields
}

MaybeLogger makes it easy to temporarily instrument code with debug logging.

func (*MaybeLogger) Attach

func (m *MaybeLogger) Attach(t testing.TB)

func (*MaybeLogger) Disable

func (m *MaybeLogger) Disable()

func (*MaybeLogger) Enable

func (m *MaybeLogger) Enable(t TestLogger)

func (*MaybeLogger) Logf

func (m *MaybeLogger) Logf(fmt string, args ...any)

type TestLogger

type TestLogger interface {
	Helper()
	Logf(string, ...any)
}

TestLogger is the interface implemented by *testing.T and various similar types and adapters.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL