Documentation ¶
Index ¶
- func ResultSetToStringSlice(ctx context.Context, s session.Session, rs sqlexec.RecordSet) ([][]string, error)
- func Rows(args ...string) [][]interface{}
- type CTestKit
- func (tk *CTestKit) CheckExecResult(ctx context.Context, affectedRows, insertID int64)
- func (tk *CTestKit) CloseSession(ctx context.Context)
- func (tk *CTestKit) ConcurrentRun(c *check.C, concurrent int, loops int, ...)
- func (tk *CTestKit) Exec(ctx context.Context, sql string, args ...interface{}) (sqlexec.RecordSet, error)
- func (tk *CTestKit) IgnoreError(_ error)
- func (tk *CTestKit) MustExec(ctx context.Context, sql string, args ...interface{})
- func (tk *CTestKit) MustQuery(ctx context.Context, sql string, args ...interface{}) *Result
- func (tk *CTestKit) OpenSession(ctx context.Context) context.Context
- func (tk *CTestKit) OpenSessionWithDB(ctx context.Context, db string) context.Context
- func (tk *CTestKit) PermInt(n int) []interface{}
- 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) ExecToErr(sql string, args ...interface{}) error
- func (tk *TestKit) GetTableID(tableName string) int64
- func (tk *TestKit) MustExec(sql string, args ...interface{})
- func (tk *TestKit) MustIndexLookup(sql 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) 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
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CTestKit ¶
type CTestKit struct {
// contains filtered or unexported fields
}
CTestKit is a utility to run sql test with concurrent execution support.
func NewCTestKit ¶
NewCTestKit returns a new *CTestKit.
func (*CTestKit) CheckExecResult ¶
CheckExecResult checks the affected rows and the insert id after executing MustExec.
func (*CTestKit) CloseSession ¶
CloseSession closes exists session from ctx.
func (*CTestKit) ConcurrentRun ¶
func (tk *CTestKit) ConcurrentRun(c *check.C, concurrent int, loops int, prepareFunc func(ctx context.Context, tk *CTestKit, concurrent int, currentLoop int) [][][]interface{}, writeFunc func(ctx context.Context, tk *CTestKit, input [][]interface{}), checkFunc func(ctx context.Context, tk *CTestKit))
ConcurrentRun run test in current. - concurrent: controls the concurrent worker count. - loops: controls run test how much times. - prepareFunc: provide test data and will be called for every loop. - checkFunc: used to do some check after all workers done. works like create table better be put in front of this method calling. see more example at TestBatchInsertWithOnDuplicate
func (*CTestKit) Exec ¶
func (tk *CTestKit) Exec(ctx context.Context, sql string, args ...interface{}) (sqlexec.RecordSet, error)
Exec executes a sql statement.
func (*CTestKit) IgnoreError ¶
IgnoreError ignores error and make errcheck tool happy. Deprecated: it's normal to ignore some error in concurrent test, but please don't use this method in other place.
func (*CTestKit) MustQuery ¶
MustQuery query the statements and returns result rows. If expected result is set it asserts the query result equals expected result.
func (*CTestKit) OpenSession ¶
OpenSession opens new session ctx if no exists one.
func (*CTestKit) OpenSessionWithDB ¶
OpenSessionWithDB opens new session ctx if no exists one and use db.
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 (*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) GetTableID ¶
GetTableID gets table ID by name.
func (*TestKit) MustIndexLookup ¶
MustIndexLookup checks whether the plan for the sql is Point_Get.
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) 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.