testutil

package
v1.1.0-beta.0...-457dcc6 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareUnorderedStringSlice

func CompareUnorderedStringSlice(a []string, b []string) bool

CompareUnorderedStringSlice compare two string slices. If a and b is exactly the same except the order, it returns true. In otherwise return false.

func DatumEqual

func DatumEqual(t testing.TB, expected, actual types.Datum, msgAndArgs ...any)

DatumEqual verifies that the actual value is equal to the expected value. For string datum, they are compared by the binary collation.

func HandleEqual

func HandleEqual(t testing.TB, expected, actual kv.Handle, msgAndArgs ...any)

HandleEqual verifies that the actual handle is equal to the expected handle.

func MaskSortHandles

func MaskSortHandles(handles []int64, shardBitsCount int, fieldType byte) []int64

MaskSortHandles sorts the handles by lowest (fieldTypeBits - 1 - shardBitsCount) bits.

func MustNewCommonHandle

func MustNewCommonHandle(t *testing.T, values ...any) kv.Handle

MustNewCommonHandle create a common handle with given values.

func RandStringRunes

func RandStringRunes(n int) string

RandStringRunes generate random string of length n.

Types

type LogHook

type LogHook struct {
	zapcore.Core
	Logs []logEntry
	// contains filtered or unexported fields
}

LogHook captures logs, mainly for testing

func WithLogHook

func WithLogHook(ctx context.Context, t *testing.T, msgFilter string) (newCtx context.Context, hook *LogHook)

WithLogHook is a helper function to use with LogHook. It returns a context whose logger is replaced with the hook.

func (*LogHook) Check

Check implements the string filter

func (*LogHook) CheckLogCount

func (h *LogHook) CheckLogCount(t *testing.T, expected int)

CheckLogCount is a helper function to assert the number of logs captured

func (*LogHook) Write

func (h *LogHook) Write(entry zapcore.Entry, fields []zapcore.Field) error

Write captures the log and save it

Jump to

Keyboard shortcuts

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