testutil

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2025 License: MPL-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PanicTB

func PanicTB() *panicTB

PanicTB is an implementation for testing.TB that panics when an error is logged or FailNow is called. This is useful to inject into test helpers in example tests where no *testing.T is available.

Doesn't fully implement testing.TB. Functions where it's used should take the more streamlined TestingTB instead.

Types

type MockT added in v0.22.0

type MockT struct {
	Failed bool
	// contains filtered or unexported fields
}

MockT mocks TestingTB. It's used to let us verify our test helpers.

func NewMockT added in v0.22.0

func NewMockT(tb TestingTB) *MockT

NewMockT initializes a new MockT. It takes another TestingTB which is usually something like a *testing.T and where logs are emitted to along with being internalized and retrievable on LogOutput.

func (*MockT) Errorf added in v0.22.0

func (t *MockT) Errorf(format string, args ...any)

func (*MockT) FailNow added in v0.22.0

func (t *MockT) FailNow()

func (*MockT) Helper added in v0.22.0

func (t *MockT) Helper()

func (*MockT) Log added in v0.22.0

func (t *MockT) Log(args ...any)

func (*MockT) LogOutput added in v0.22.0

func (t *MockT) LogOutput() string

func (*MockT) Logf added in v0.22.0

func (t *MockT) Logf(format string, args ...any)

type TestingTB

type TestingTB interface {
	Errorf(format string, args ...any)
	FailNow()
	Helper()
	Log(args ...any)
	Logf(format string, args ...any)
}

TestingT is an interface wrapper around *testing.T that's implemented by all of *testing.T, *testing.F, and *testing.B.

It's used internally to verify that River's test assertions are working as expected.

Jump to

Keyboard shortcuts

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