testkit

package
v0.0.0-...-b75dac1 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MockGC

func MockGC(tk *TestKit) (string, string, string, func())

MockGC is used to make GC work in the test environment.

func Rows

func Rows(args ...string) [][]interface{}

Rows is similar to RowsWithSep, use white space as separator string.

func WithPruneMode

func WithPruneMode(tk *TestKit, mode variable.PartitionPruneMode, f func())

WithPruneMode run test case under prune mode.

Types

type Result

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

Result is the result returned by MustQuery.

func (*Result) Check

func (res *Result) Check(expected [][]interface{})

Check asserts the result equals the expected results.

func (*Result) CheckAt

func (res *Result) CheckAt(cols []int, expected [][]interface{})

CheckAt asserts the result of selected columns equals the expected results.

func (*Result) Rows

func (res *Result) Rows() [][]interface{}

Rows returns the result data.

func (*Result) Sort

func (res *Result) Sort() *Result

Sort sorts and return the result.

type TestKit

type TestKit struct {
	Se session.Session
	// contains filtered or unexported fields
}

TestKit is a utility to run sql test.

func NewTestKit

func NewTestKit(c *check.C, store kv.Storage) *TestKit

NewTestKit returns a new *TestKit.

func NewTestKitWithInit

func NewTestKitWithInit(c *check.C, store kv.Storage) *TestKit

NewTestKitWithInit returns a new *TestKit and creates a session.

func NewTestKitWithSession

func NewTestKitWithSession(c *check.C, store kv.Storage, se session.Session) *TestKit

NewTestKitWithSession returns a new *TestKit with a session.

func (*TestKit) CheckExecResult

func (tk *TestKit) CheckExecResult(affectedRows, insertID int64)

CheckExecResult checks the affected rows and the insert id after executing MustExec.

func (*TestKit) CheckLastMessage

func (tk *TestKit) CheckLastMessage(msg string)

CheckLastMessage checks last message after executing MustExec

func (*TestKit) Exec

func (tk *TestKit) Exec(sql string, args ...interface{}) (sqlexec.RecordSet, error)

Exec executes a sql statement using the prepared stmt API

func (*TestKit) ExecInc

func (tk *TestKit) ExecInc(sql string, args ...interface{}) (sqlexec.RecordSet, error)

ExecInc executes a sql statement using the prepared stmt API

func (*TestKit) ExecToErr

func (tk *TestKit) ExecToErr(sql string, args ...interface{}) error

ExecToErr executes a sql statement and discard results.

func (*TestKit) GetConnectionID

func (tk *TestKit) GetConnectionID()

GetConnectionID get the connection ID for tk.Se

func (*TestKit) GetTableID

func (tk *TestKit) GetTableID(tableName string) int64

GetTableID gets table ID by name.

func (*TestKit) HasPlan

func (tk *TestKit) HasPlan(sql string, plan string, args ...interface{}) bool

HasPlan checks if the result execution plan contains specific plan.

func (*TestKit) MayQuery

func (tk *TestKit) MayQuery(sql string, args ...interface{}) *Result

MayQuery query the statements and returns result rows if result set is returned. If expected result is set it asserts the query result equals expected result.

func (*TestKit) MustExec

func (tk *TestKit) MustExec(sql string, args ...interface{})

MustExec executes a sql statement and asserts nil error.

func (*TestKit) MustExecInc

func (tk *TestKit) MustExecInc(sql string, args ...interface{})

MustExecInc executes a sql statement and asserts nil error.

func (*TestKit) MustGetErrCode

func (tk *TestKit) MustGetErrCode(sql string, errCode int)

MustGetErrCode executes a sql statement and assert it's error code.

func (*TestKit) MustGetErrMsg

func (tk *TestKit) MustGetErrMsg(sql string, errStr string)

MustGetErrMsg executes a sql statement and assert it's error message.

func (*TestKit) MustIndexLookup

func (tk *TestKit) MustIndexLookup(sql string, args ...interface{}) *Result

MustIndexLookup checks whether the plan for the sql is IndexLookUp.

func (*TestKit) MustNoGlobalStats

func (tk *TestKit) MustNoGlobalStats(table string) bool

MustNoGlobalStats checks if there is no global stats.

func (*TestKit) MustPartition

func (tk *TestKit) MustPartition(sql string, partitions string, args ...interface{}) *Result

MustPartition checks if the result execution plan must read specific partitions.

func (*TestKit) MustPointGet

func (tk *TestKit) MustPointGet(sql string, args ...interface{}) *Result

MustPointGet checks whether the plan for the sql is Point_Get.

func (*TestKit) MustQuery

func (tk *TestKit) MustQuery(sql string, args ...interface{}) *Result

MustQuery query the statements and returns result rows. If expected result is set it asserts the query result equals expected result.

func (*TestKit) MustQueryInc

func (tk *TestKit) MustQueryInc(sql string, args ...interface{}) *Result

MustQueryInc query the statements and returns result rows. If expected result is set it asserts the query result equals expected result.

func (*TestKit) MustTableDual

func (tk *TestKit) MustTableDual(sql string, args ...interface{}) *Result

MustTableDual checks whether the plan for the sql is TableDual.

func (*TestKit) MustUseIndex

func (tk *TestKit) MustUseIndex(sql string, index string, args ...interface{}) bool

MustUseIndex checks if the result execution plan contains specific index(es).

func (*TestKit) QueryToErr

func (tk *TestKit) QueryToErr(sql string, args ...interface{}) error

QueryToErr executes a sql statement and discard results.

func (*TestKit) ResultSetToResult

func (tk *TestKit) ResultSetToResult(rs sqlexec.RecordSet, comment check.CommentInterface) *Result

ResultSetToResult converts sqlexec.RecordSet to testkit.Result. It is used to check results of execute statement in binary mode.

func (*TestKit) ResultSetToResultWithCtx

func (tk *TestKit) ResultSetToResultWithCtx(ctx context.Context, rs sqlexec.RecordSet, comment check.CommentInterface) *Result

ResultSetToResultWithCtx converts sqlexec.RecordSet to testkit.Result.

func (*TestKit) UsedPartitions

func (tk *TestKit) UsedPartitions(sql string, args ...interface{}) *Result

UsedPartitions returns the partition names that will be used or all/dual.

Jump to

Keyboard shortcuts

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