test

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloneMessage

func CloneMessage[T proto.Message](msg T) T

CloneMessage allows for type safe cloning of protobuf messages.

func Context

func Context(c Cleaner) context.Context

func Equal

func Equal[T comparable](t TestingT, want T, got T, format string, a ...any)

func EqualDiff added in v0.3.0

func EqualDiff(t TestingT,
	want any, got any,
	format string, a ...any,
)

EqualDiff runs a cmp.Diff to do a deep equal check with readable diff output.

func EqualMessage

func EqualMessage(t TestingT,
	want proto.Message, got proto.Message,
	format string, a ...any,
)

EqualMessage runs a cmp.Diff with protobuf-specific options.

func IsTwirpError

func IsTwirpError(
	t TestingT, err error, code twirp.ErrorCode,
)

func Must

func Must(t TestingT, err error, format string, a ...any)

func MustNot

func MustNot(t TestingT, err error, format string, a ...any)

func NewLogHandler

func NewLogHandler(t Logger, level slog.Level) slog.Handler

func NotNil

func NotNil[T any](t TestingT, v *T, format string, a ...any)

Types

type Cleaner

type Cleaner interface {
	Cleanup(fn func())
}

type LogHandler

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

func (*LogHandler) Enabled

func (h *LogHandler) Enabled(ctx context.Context, level slog.Level) bool

func (*LogHandler) Handle

func (h *LogHandler) Handle(ctx context.Context, r slog.Record) error

func (*LogHandler) WithAttrs

func (h *LogHandler) WithAttrs(attrs []slog.Attr) slog.Handler

func (*LogHandler) WithGroup

func (h *LogHandler) WithGroup(name string) slog.Handler

func (*LogHandler) Write

func (h *LogHandler) Write(data []byte) (int, error)

type Logger

type Logger interface {
	Log(args ...any)
}

type TestingT

type TestingT interface {
	Helper()
	Fatalf(format string, args ...any)
	Logf(format string, args ...any)
}

Jump to

Keyboard shortcuts

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