testutil

package
v0.0.0-...-37ba7e9 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DatumEquals check.Checker = &datumEqualsChecker{
	&check.CheckerInfo{Name: "DatumEquals", Params: []string{"obtained", "expected"}},
}

DatumEquals checker verifies that the obtained value is equal to the expected value. For example:

c.Assert(value, DatumEquals, NewDatum(42))

TODO: please use trequire.DatumEqual to replace this function to migrate to testify

View Source
var HandleEquals = &handleEqualsChecker{
	&check.CheckerInfo{Name: "HandleEquals", Params: []string{"obtained", "expected"}},
}

HandleEquals checker verifies that the obtained handle is equal to the expected handle. For example:

c.Assert(value, HandleEquals, kv.IntHandle(42))

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 MaskSortHandles

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

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

func MustNewCommonHandle

func MustNewCommonHandle(c *check.C, values ...interface{}) kv.Handle

MustNewCommonHandle create a common handle with given values. TODO: please use testkit.MustNewCommonHandle to replace this function to migrate to testify

func RowsWithSep

func RowsWithSep(sep string, args ...string) [][]interface{}

RowsWithSep is a convenient function to wrap args to a slice of []interface. The arg represents a row, split by sep.

Types

type CommonHandleSuite

type CommonHandleSuite struct {
	IsCommonHandle bool
}

CommonHandleSuite is used to adapt kv.CommonHandle to existing kv.IntHandle tests.

Usage:
 type MyTestSuite struct {
     CommonHandleSuite
 }
 func (s *MyTestSuite) TestSomething(c *C) {
     // ...
     s.RerunWithCommonHandleEnabled(c, s.TestSomething)
 }

func (*CommonHandleSuite) NewHandle

func (chs *CommonHandleSuite) NewHandle() *commonHandleSuiteNewHandleBuilder

NewHandle create a handle according to CommonHandleSuite.IsCommonHandle.

func (*CommonHandleSuite) RerunWithCommonHandleEnabled

func (chs *CommonHandleSuite) RerunWithCommonHandleEnabled(c *check.C, f func(*check.C))

RerunWithCommonHandleEnabled runs a test function with IsCommonHandle enabled.

type TestData

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

TestData stores all the data of a test suite. TODO: please use testkit.TestData to migrate to testify

func LoadTestSuiteData

func LoadTestSuiteData(dir, suiteName string) (res TestData, err error)

LoadTestSuiteData loads test suite data from file.

func (*TestData) ConvertRowsToStrings

func (t *TestData) ConvertRowsToStrings(rows [][]interface{}) (rs []string)

ConvertRowsToStrings converts [][]interface{} to []string.

func (*TestData) ConvertSQLWarnToStrings

func (t *TestData) ConvertSQLWarnToStrings(warns []stmtctx.SQLWarn) (rs []string)

ConvertSQLWarnToStrings converts []SQLWarn to []string.

func (*TestData) GenerateOutputIfNeeded

func (t *TestData) GenerateOutputIfNeeded() error

GenerateOutputIfNeeded generate the output file.

func (*TestData) GetTestCases

func (t *TestData) GetTestCases(c *check.C, in interface{}, out interface{})

GetTestCases gets the test cases for a test function.

func (*TestData) GetTestCasesByName

func (t *TestData) GetTestCasesByName(caseName string, c *check.C, in interface{}, out interface{})

GetTestCasesByName gets the test cases for a test function by its name.

func (*TestData) OnRecord

func (t *TestData) OnRecord(updateFunc func())

OnRecord execute the function to update result.

Jump to

Keyboard shortcuts

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