testutil

package
v1.1.10 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal[T any](t TestingT, expected, actual T, opts ...Option[T])

Equal compares the expected and actual values of type T.

It fails the test immediately if the values are not equal, and reports the difference using cmp.Diff.

Options can be provided via opts to customize the comparison.

func NewSpanID

func NewSpanID(t *testing.T, v string) trace.SpanID

func NewTraceID

func NewTraceID(t *testing.T, v string) trace.TraceID

func NewTraceState

func NewTraceState(t *testing.T, value string) trace.TraceState

Types

type MockOption

type MockOption[T any] struct {
	mock.Mock
}

MockOption is an autogenerated mock type for the Option type

func NewMockOption

func NewMockOption[T any](t interface {
	mock.TestingT
	Cleanup(func())
}) *MockOption[T]

NewMockOption creates a new instance of MockOption. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockOption[T]) EXPECT

func (_m *MockOption[T]) EXPECT() *MockOption_Expecter[T]

func (*MockOption[T]) Execute added in v1.0.10

func (_m *MockOption[T]) Execute() cmp.Option

Execute provides a mock function with no fields

type MockOption_Execute_Call added in v1.0.10

type MockOption_Execute_Call[T any] struct {
	*mock.Call
}

MockOption_Execute_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Execute'

func (*MockOption_Execute_Call[T]) Return added in v1.0.10

func (*MockOption_Execute_Call[T]) Run added in v1.0.10

func (_c *MockOption_Execute_Call[T]) Run(run func()) *MockOption_Execute_Call[T]

func (*MockOption_Execute_Call[T]) RunAndReturn added in v1.0.10

func (_c *MockOption_Execute_Call[T]) RunAndReturn(run func() cmp.Option) *MockOption_Execute_Call[T]

type MockOption_Expecter

type MockOption_Expecter[T any] struct {
	// contains filtered or unexported fields
}

func (*MockOption_Expecter[T]) Execute added in v1.0.10

func (_e *MockOption_Expecter[T]) Execute() *MockOption_Execute_Call[T]

Execute is a helper method to define mock.On call

type MockTestingT

type MockTestingT struct {
	mock.Mock
}

MockTestingT is an autogenerated mock type for the TestingT type

func NewMockTestingT

func NewMockTestingT(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockTestingT

NewMockTestingT creates a new instance of MockTestingT. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockTestingT) EXPECT

func (_m *MockTestingT) EXPECT() *MockTestingT_Expecter

func (*MockTestingT) Errorf

func (_mock *MockTestingT) Errorf(format string, args ...any)

Errorf provides a mock function for the type MockTestingT

func (*MockTestingT) FailNow

func (_mock *MockTestingT) FailNow()

FailNow provides a mock function for the type MockTestingT

func (*MockTestingT) Helper

func (_mock *MockTestingT) Helper()

Helper provides a mock function for the type MockTestingT

type MockTestingT_Errorf_Call

type MockTestingT_Errorf_Call struct {
	*mock.Call
}

MockTestingT_Errorf_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Errorf'

func (*MockTestingT_Errorf_Call) Return

func (*MockTestingT_Errorf_Call) Run

func (_c *MockTestingT_Errorf_Call) Run(run func(format string, args ...any)) *MockTestingT_Errorf_Call

func (*MockTestingT_Errorf_Call) RunAndReturn

func (_c *MockTestingT_Errorf_Call) RunAndReturn(run func(format string, args ...any)) *MockTestingT_Errorf_Call

type MockTestingT_Expecter

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

func (*MockTestingT_Expecter) Errorf

func (_e *MockTestingT_Expecter) Errorf(format interface{}, args ...interface{}) *MockTestingT_Errorf_Call

Errorf is a helper method to define mock.On call

  • format string
  • args ...any

func (*MockTestingT_Expecter) FailNow

FailNow is a helper method to define mock.On call

func (*MockTestingT_Expecter) Helper

Helper is a helper method to define mock.On call

type MockTestingT_FailNow_Call

type MockTestingT_FailNow_Call struct {
	*mock.Call
}

MockTestingT_FailNow_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FailNow'

func (*MockTestingT_FailNow_Call) Return

func (*MockTestingT_FailNow_Call) Run

func (*MockTestingT_FailNow_Call) RunAndReturn

func (_c *MockTestingT_FailNow_Call) RunAndReturn(run func()) *MockTestingT_FailNow_Call

type MockTestingT_Helper_Call

type MockTestingT_Helper_Call struct {
	*mock.Call
}

MockTestingT_Helper_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Helper'

func (*MockTestingT_Helper_Call) Return

func (*MockTestingT_Helper_Call) Run

func (*MockTestingT_Helper_Call) RunAndReturn

func (_c *MockTestingT_Helper_Call) RunAndReturn(run func()) *MockTestingT_Helper_Call

type Option

type Option[T any] func() cmp.Option

Option represents a comparer option that applies to a specific type T

func EquateComparable

func EquateComparable[T any](typs ...any) Option[T]

func IgnoreMapEntries

func IgnoreMapEntries[K comparable, V any](predicate func(K, V) bool) Option[map[K]V]

IgnoreMapEntries returns an Option that causes the comparison to skip map entries that satisfy the given predicate function

func IgnoreSliceElements

func IgnoreSliceElements[T any](predicate func(T) bool) Option[[]T]

func IgnoreSliceMapEntries

func IgnoreSliceMapEntries[K comparable, V any](predicate func(K, V) bool) Option[[]map[K]V]

IgnoreSliceMapEntries returns an Option that causes the comparison to skip map entries that satisfy the given predicate function

func IgnoreSliceOrder added in v1.0.6

func IgnoreSliceOrder[T any]() Option[[]T]

func IgnoreUnexported

func IgnoreUnexported[T any](typs ...any) Option[T]

func SortSlices added in v1.0.6

func SortSlices[S []T, T any](cmpFunc func(T, T) int) Option[S]

type TestingT

type TestingT interface {
	Helper()

	Errorf(format string, args ...any)

	FailNow()
}

Jump to

Keyboard shortcuts

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