Documentation
¶
Index ¶
- func MockGC(tk *TestKit) (string, string, string, func())
- func Rows(args ...string) [][]interface{}
- func WithPruneMode(tk *TestKit, mode variable.PartitionPruneMode, f func())
- type Result
- type TestKit
- func (tk *TestKit) CheckExecResult(affectedRows, insertID int64)
- func (tk *TestKit) CheckLastMessage(msg string)
- func (tk *TestKit) Exec(sql string, args ...interface{}) (sqlexec.RecordSet, error)
- func (tk *TestKit) ExecInc(sql string, args ...interface{}) (sqlexec.RecordSet, error)
- func (tk *TestKit) ExecToErr(sql string, args ...interface{}) error
- func (tk *TestKit) GetConnectionID()
- func (tk *TestKit) GetTableID(tableName string) int64
- func (tk *TestKit) HasPlan(sql string, plan string, args ...interface{}) bool
- func (tk *TestKit) MayQuery(sql string, args ...interface{}) *Result
- func (tk *TestKit) MustExec(sql string, args ...interface{})
- func (tk *TestKit) MustExecInc(sql string, args ...interface{})
- func (tk *TestKit) MustGetErrCode(sql string, errCode int)
- func (tk *TestKit) MustGetErrMsg(sql string, errStr string)
- func (tk *TestKit) MustIndexLookup(sql string, args ...interface{}) *Result
- func (tk *TestKit) MustNoGlobalStats(table string) bool
- func (tk *TestKit) MustPartition(sql string, partitions string, args ...interface{}) *Result
- func (tk *TestKit) MustPointGet(sql string, args ...interface{}) *Result
- func (tk *TestKit) MustQuery(sql string, args ...interface{}) *Result
- func (tk *TestKit) MustQueryInc(sql string, args ...interface{}) *Result
- func (tk *TestKit) MustTableDual(sql string, args ...interface{}) *Result
- func (tk *TestKit) MustUseIndex(sql string, index string, args ...interface{}) bool
- func (tk *TestKit) QueryToErr(sql string, args ...interface{}) error
- func (tk *TestKit) ResultSetToResult(rs sqlexec.RecordSet, comment check.CommentInterface) *Result
- func (tk *TestKit) ResultSetToResultWithCtx(ctx context.Context, rs sqlexec.RecordSet, comment check.CommentInterface) *Result
- func (tk *TestKit) UsedPartitions(sql string, args ...interface{}) *Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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.
type TestKit ¶
TestKit is a utility to run sql test.
func NewTestKit ¶
NewTestKit returns a new *TestKit.
func NewTestKitWithInit ¶
NewTestKitWithInit returns a new *TestKit and creates a session.
func NewTestKitWithSession ¶
NewTestKitWithSession returns a new *TestKit with a session.
func (*TestKit) CheckExecResult ¶
CheckExecResult checks the affected rows and the insert id after executing MustExec.
func (*TestKit) CheckLastMessage ¶
CheckLastMessage checks last message after executing MustExec
func (*TestKit) GetConnectionID ¶
func (tk *TestKit) GetConnectionID()
GetConnectionID get the connection ID for tk.Se
func (*TestKit) GetTableID ¶
GetTableID gets table ID by name.
func (*TestKit) MayQuery ¶
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) MustExecInc ¶
MustExecInc executes a sql statement and asserts nil error.
func (*TestKit) MustGetErrCode ¶
MustGetErrCode executes a sql statement and assert it's error code.
func (*TestKit) MustGetErrMsg ¶
MustGetErrMsg executes a sql statement and assert it's error message.
func (*TestKit) MustIndexLookup ¶
MustIndexLookup checks whether the plan for the sql is IndexLookUp.
func (*TestKit) MustNoGlobalStats ¶
MustNoGlobalStats checks if there is no global stats.
func (*TestKit) MustPartition ¶
MustPartition checks if the result execution plan must read specific partitions.
func (*TestKit) MustPointGet ¶
MustPointGet checks whether the plan for the sql is Point_Get.
func (*TestKit) MustQuery ¶
MustQuery query the statements and returns result rows. If expected result is set it asserts the query result equals expected result.
func (*TestKit) MustQueryInc ¶
MustQueryInc query the statements and returns result rows. If expected result is set it asserts the query result equals expected result.
func (*TestKit) MustTableDual ¶
MustTableDual checks whether the plan for the sql is TableDual.
func (*TestKit) MustUseIndex ¶
MustUseIndex checks if the result execution plan contains specific index(es).
func (*TestKit) QueryToErr ¶
QueryToErr executes a sql statement and discard results.
func (*TestKit) ResultSetToResult ¶
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 ¶
UsedPartitions returns the partition names that will be used or all/dual.