it

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: MPL-2.0 Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitOutputPrefs

func InitOutputPrefs(opts ...OutputOpt)

InitOutputPrefs sets the default output prefs, typically during init(). Calls to this function outside of init() are unsupported and may panic or produce unexpected results.

func Must

func Must[T any](t TestingT, actual T, matchFn Match[T], opts ...OutputOpt)

Must takes a TestingT and an actual, checks to see if it matches, and outputs the returned result.

Types

type Match

type Match[T any] func(T) Result

Match is a function which matches against an actual.

type OutputOpt

type OutputOpt func(outputPrefs) outputPrefs

OutputOpt is an option function for changing how a Result is handled when outputing test results.

func Describe

func Describe(desc string) OutputOpt

Describe returns an OutputOpt which adds extra context about the assertion in any output that may result.

func OutputOnPass

func OutputOnPass() OutputOpt

OutputOnPass returns an OutputOpt which tells assertions to still output passing results.

func WithCtx

func WithCtx(ctx context.Context) OutputOpt

WithCtx returns an OutputOpt that sets the context.Context passed to any result methods. This may be used to pass formatters, differs, color preferences, etc.

By default, assertions use context.Background().

type Result

type Result interface {
	Matched() bool
	Describe(_ context.Context, passed bool) string
}

type TestingT

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

TestingT contains the methods from *testing.T that we Must uses.

Jump to

Keyboard shortcuts

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