testhooks

package
v1.27.1 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Options(
	fx.Provide(func() (_ TestHooks) { return }),
)

Functions

func Call

func Call(_ TestHooks, key Key)

Call calls a func() hook if present.

TestHooks should be used very sparingly, see comment on TestHooks.

func Get

func Get[T any](_ TestHooks, key Key) (T, bool)

Get gets the value of a test hook. In production mode it always returns the zero value and false, which hopefully the compiler will inline and remove the hook as dead code.

TestHooks should be used very sparingly, see comment on TestHooks.

Types

type Key

type Key int
const (
	MatchingDisableSyncMatch Key = iota
	MatchingLBForceReadPartition
	MatchingLBForceWritePartition
	UpdateWithStartInBetweenLockAndStart
)

type TestHooks

type TestHooks struct{}

TestHooks (in production mode) is an empty struct just so the build works. See TestHooks in test_impl.go.

TestHooks are an inherently unclean way of writing tests. They require mixing test-only concerns into production code. In general you should prefer other ways of writing tests wherever possible, and only use TestHooks sparingly, as a last resort.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳