Documentation
¶
Index ¶
- func CreateMockStore(t testing.TB, opts ...mockstore.MockTiKVStoreOption) (store kv.Storage, clean func())
- func CreateMockStoreAndDomain(t testing.TB, opts ...mockstore.MockTiKVStoreOption) (kv.Storage, *domain.Domain, func())
- func CreateMockStoreWithOracle(t testing.TB, oracle oracle.Oracle, opts ...mockstore.MockTiKVStoreOption) (kv.Storage, *domain.Domain, func())
- func MustNewCommonHandle(t *testing.T, values ...interface{}) kv.Handle
- func Rows(args ...string) [][]interface{}
- func RowsWithSep(sep string, args ...string) [][]interface{}
- type AsyncTestKit
- func (tk *AsyncTestKit) CloseSession(ctx context.Context)
- func (tk *AsyncTestKit) ConcurrentRun(concurrent int, loops int, ...)
- func (tk *AsyncTestKit) Exec(ctx context.Context, sql string, args ...interface{}) (sqlexec.RecordSet, error)
- func (tk *AsyncTestKit) MustExec(ctx context.Context, sql string, args ...interface{})
- func (tk *AsyncTestKit) MustQuery(ctx context.Context, sql string, args ...interface{}) *Result
- func (tk *AsyncTestKit) OpenSession(ctx context.Context, db string) context.Context
- type DBTestKit
- type Result
- type TestKit
- func (tk *TestKit) Exec(sql string, args ...interface{}) (sqlexec.RecordSet, error)
- func (tk *TestKit) ExecToErr(sql string, args ...interface{}) error
- func (tk *TestKit) HasPlan(sql string, plan string, args ...interface{}) bool
- func (tk *TestKit) MustExec(sql string, args ...interface{})
- func (tk *TestKit) MustGetErrCode(sql string, errCode int)
- func (tk *TestKit) MustGetErrMsg(sql string, errStr string)
- func (tk *TestKit) MustQuery(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) RefreshConnectionID()
- func (tk *TestKit) RefreshSession()
- func (tk *TestKit) ResultSetToResult(rs sqlexec.RecordSet, comment string) *Result
- func (tk *TestKit) ResultSetToResultWithCtx(ctx context.Context, rs sqlexec.RecordSet, comment string) *Result
- func (tk *TestKit) Session() session.Session
- func (tk *TestKit) SetSession(session session.Session)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateMockStore ¶
func CreateMockStore(t testing.TB, opts ...mockstore.MockTiKVStoreOption) (store kv.Storage, clean func())
CreateMockStore return a new mock kv.Storage.
func CreateMockStoreAndDomain ¶
func CreateMockStoreAndDomain(t testing.TB, opts ...mockstore.MockTiKVStoreOption) (kv.Storage, *domain.Domain, func())
CreateMockStoreAndDomain return a new mock kv.Storage and *domain.Domain.
func CreateMockStoreWithOracle ¶
func CreateMockStoreWithOracle(t testing.TB, oracle oracle.Oracle, opts ...mockstore.MockTiKVStoreOption) (kv.Storage, *domain.Domain, func())
CreateMockStoreWithOracle returns a new mock kv.Storage and *domain.Domain, providing the oracle for the store.
func MustNewCommonHandle ¶
MustNewCommonHandle create a common handle with given values.
func Rows ¶
func Rows(args ...string) [][]interface{}
Rows is similar to RowsWithSep, use white space as separator string.
func RowsWithSep ¶
RowsWithSep is a convenient function to wrap args to a slice of []interface. The arg represents a row, split by sep.
Types ¶
type AsyncTestKit ¶
type AsyncTestKit struct {
// contains filtered or unexported fields
}
AsyncTestKit is a utility to run sql concurrently.
func NewAsyncTestKit ¶
func NewAsyncTestKit(t *testing.T, store kv.Storage) *AsyncTestKit
NewAsyncTestKit returns a new *AsyncTestKit.
func (*AsyncTestKit) CloseSession ¶
func (tk *AsyncTestKit) CloseSession(ctx context.Context)
CloseSession closes exists session from ctx.
func (*AsyncTestKit) ConcurrentRun ¶
func (tk *AsyncTestKit) ConcurrentRun( concurrent int, loops int, prepareFunc func(ctx context.Context, tk *AsyncTestKit, concurrent int, currentLoop int) [][][]interface{}, writeFunc func(ctx context.Context, tk *AsyncTestKit, input [][]interface{}), checkFunc func(ctx context.Context, tk *AsyncTestKit), )
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 (*AsyncTestKit) Exec ¶
func (tk *AsyncTestKit) Exec(ctx context.Context, sql string, args ...interface{}) (sqlexec.RecordSet, error)
Exec executes a sql statement.
func (*AsyncTestKit) MustExec ¶
func (tk *AsyncTestKit) MustExec(ctx context.Context, sql string, args ...interface{})
MustExec executes a sql statement and asserts nil error.
func (*AsyncTestKit) MustQuery ¶
func (tk *AsyncTestKit) MustQuery(ctx context.Context, 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 (*AsyncTestKit) OpenSession ¶
OpenSession opens new session ctx if no exists one and use db.
type DBTestKit ¶
type DBTestKit struct {
// contains filtered or unexported fields
}
DBTestKit is a utility to run sql with a db connection.
func NewDBTestKit ¶
NewDBTestKit returns a new *DBTestKit.
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
Result is the result returned by MustQuery.
type TestKit ¶
type TestKit struct {
// contains filtered or unexported fields
}
TestKit is a utility to run sql test.
func NewTestKit ¶
NewTestKit returns a new *TestKit.
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) MustQuery ¶
MustQuery query the statements and returns result rows. If expected result is set it asserts the query result equals expected result.
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) RefreshConnectionID ¶
func (tk *TestKit) RefreshConnectionID()
RefreshConnectionID refresh the connection ID for session of the testkit
func (*TestKit) RefreshSession ¶
func (tk *TestKit) RefreshSession()
RefreshSession set a new session for the testkit
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 string) *Result
ResultSetToResultWithCtx converts sqlexec.RecordSet to testkit.Result.
func (*TestKit) SetSession ¶
SetSession set the session of testkit