Documentation ¶
Index ¶
- Constants
- func ClearMySQLTables(t testutils.TestingT, vdb *database.VersionedDB)
- func LocalTestDatabaseConfig(m []database.MigrationStep) *database.DatabaseConfig
- func LocalTestRootDatabaseConfig(m []database.MigrationStep) *database.DatabaseConfig
- func MySQLVersioningTests(t testutils.TestingT, dbName string, migrationSteps []database.MigrationStep)
- type LockDB
- type MySQLTestDatabase
Constants ¶
const ( // String to open a local database for testing. The string formatting // parameters are: username, password, database. MYSQL_DB_OPEN = "%s:%s@tcp(localhost:3306)/%s?parseTime=true" // Name of the MySQL lock SQL_LOCK = "mysql_testlock" // Name of the shared test database. TEST_DB_HOST = "localhost" TEST_DB_PORT = 3306 TEST_DB_NAME = "sk_testing" // Names of test users. These users should have no password and be // limited to accessing the sk_testing database. USER_ROOT = "test_root" USER_RW = "test_rw" // Empty password for testing. TEST_PASSWORD = "" )
Connection string to the local MySQL database for testing.
Variables ¶
This section is empty.
Functions ¶
func ClearMySQLTables ¶
func ClearMySQLTables(t testutils.TestingT, vdb *database.VersionedDB)
Remove all tables from the database.
func LocalTestDatabaseConfig ¶
func LocalTestDatabaseConfig(m []database.MigrationStep) *database.DatabaseConfig
LocalTestDatabaseConfig returns a DatabaseConfig appropriate for local testing.
func LocalTestRootDatabaseConfig ¶
func LocalTestRootDatabaseConfig(m []database.MigrationStep) *database.DatabaseConfig
LocalTestRootDatabaseConfig returns a DatabaseConfig appropriate for local testing, with root access.
func MySQLVersioningTests ¶
func MySQLVersioningTests(t testutils.TestingT, dbName string, migrationSteps []database.MigrationStep)
Creates an MySQL test database and runs migration tests against it using the given migration steps. See Get for required credentials. The test assumes that the database is empty and that the readwrite user is not allowed to create/drop/alter tables.
Types ¶
type LockDB ¶
func GetMySQlLock ¶
func GetMySQlLock(t testutils.TestingT, conf *database.DatabaseConfig) *LockDB
Get a lock from MySQL to serialize DB tests.
type MySQLTestDatabase ¶
type MySQLTestDatabase struct {
// contains filtered or unexported fields
}
MySQLTestDatabase is a convenience struct for using a test database which starts in a clean state.
func SetupMySQLTestDatabase ¶
func SetupMySQLTestDatabase(t testutils.TestingT, migrationSteps []database.MigrationStep) *MySQLTestDatabase
SetupMySQLTestDatabase returns a MySQLTestDatabase in a clean state. It must be closed after use.
Example usage:
db := SetupMySQLTestDatabase(t, migrationSteps) defer util.Close(db) ... Tests here ...
func (*MySQLTestDatabase) Close ¶
func (d *MySQLTestDatabase) Close(t testutils.TestingT)