Documentation ¶
Index ¶
Constants ¶
const (
TestDataDirPath = "testdata"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MysqlTestSuite ¶
type MysqlTestSuite struct { suite.Suite Testdb string Tables []string Config *mysql.Config Manager mysql.Manager }
func NewMysqlTestSuite ¶
func NewMysqlTestSuite(db string, tables []string) *MysqlTestSuite
NewMysqlTestSuite @p db is the name of test db and tables are table creation SQL statements. DB will be created, so does tables, on SetupTest. If you pass different @p db for suites in different packages, you can test them in parallel.
func NewMysqlTestSuiteWithConfig ¶
func NewMysqlTestSuiteWithConfig(config *mysql.Config, db string, tables []string) *MysqlTestSuite
NewMysqlTestSuiteWithConfig connect to MysqlServer according to @p config, @p db is the name of test db and tables are table creation SQL statements. DB will be created, so does tables, on SetupTest. If you pass different @p db for suites in different packages, you can test them in parallel.
func (*MysqlTestSuite) DumpState ¶
func (suite *MysqlTestSuite) DumpState(filename string, dumper Dumper)
Dumpstate dump state to the file. For example DumpState(ctx, "sample1.golden.json") will dump (insert) bytes from dumper.dump() to "testdata/sample1.golden.json".
func (*MysqlTestSuite) GetConn ¶
func (suite *MysqlTestSuite) GetConn() *sql.DB
returns a raw *sql.DB connection.
func (*MysqlTestSuite) Golden ¶
func (suite *MysqlTestSuite) Golden(dbName string, dumper Dumper)
func (*MysqlTestSuite) LoadState ¶
func (suite *MysqlTestSuite) LoadState(filename string, loader Loader)
LoadState load state from the file to DB. For example LoadState(ctx, "sample1.input.json") will load (insert) from "testdata/sample1.input.json" to table
func (*MysqlTestSuite) SetupTest ¶
func (suite *MysqlTestSuite) SetupTest()
setup the database to a clean state: tables have been created according to the schema, empty.