Documentation ¶
Index ¶
- Variables
- func Datasource(options ...DatasourceOption) string
- func Dircopy(from string, to string) error
- type DatasourceOption
- func WithDbname(s string) DatasourceOption
- func WithHost(s string) DatasourceOption
- func WithMultiStatements(t bool) DatasourceOption
- func WithParseTime(t bool) DatasourceOption
- func WithPassword(s string) DatasourceOption
- func WithPort(p int) DatasourceOption
- func WithProto(s string) DatasourceOption
- func WithSocket(s string) DatasourceOption
- func WithUser(s string) DatasourceOption
- type MysqldConfig
- type TestMysqld
- func (m *TestMysqld) AssertNotRunning() error
- func (m *TestMysqld) BaseDir() string
- func (m *TestMysqld) ConnectString(port int) string
- func (m *TestMysqld) DSN(options ...DatasourceOption) string
- func (m *TestMysqld) Datasource(dbname string, user string, pass string, port int, options ...DatasourceOption) string
- func (m *TestMysqld) ReadLog() ([]byte, error)
- func (m *TestMysqld) Setup() error
- func (m *TestMysqld) Socket() string
- func (m *TestMysqld) Start() error
- func (m *TestMysqld) Stop()
Constants ¶
This section is empty.
Variables ¶
var MysqlSearchPaths = []string{ ".", filepath.FromSlash("/usr/local/mysql/bin"), }
var MysqldSearchDirs = []string{
"bin", "libexec", "sbin",
}
Functions ¶
func Datasource ¶
func Datasource(options ...DatasourceOption) string
Datasource is a utility function to format the DSN that can be passed to mysqld driver.
Types ¶
type DatasourceOption ¶
type DatasourceOption interface { Name() string Value() interface{} }
DatasourceOption is an object that can be passed to the various methods that generate datasource names
func WithDbname ¶
func WithDbname(s string) DatasourceOption
WithDbname specifies the database name to connect.
func WithHost ¶
func WithHost(s string) DatasourceOption
WithHost specifies the host name to connect. This is only respected if connection protocol is "tcp"
func WithMultiStatements ¶
func WithMultiStatements(t bool) DatasourceOption
WithMultiStatements specifies whethere the `multiStatements` parameter should be appended to the DSN
func WithParseTime ¶
func WithParseTime(t bool) DatasourceOption
WithParseTime specifies whethere the `parseTime` parameter should be appended to the DSN
func WithPassword ¶
func WithPassword(s string) DatasourceOption
WithPassword specifies the password to use when authenticating.
func WithPort ¶
func WithPort(p int) DatasourceOption
WithPort specifies the port number to connect. This is only respected if connection protocol is "tcp"
func WithProto ¶
func WithProto(s string) DatasourceOption
WithProto specifies the connection protocol ("unix" or "tcp")
func WithSocket ¶
func WithSocket(s string) DatasourceOption
WithProto specifies the path to the unix socket This is only respected if connection protocol is "unix"
func WithUser ¶
func WithUser(s string) DatasourceOption
WithUser specifies the user name to use when authenticating.
type MysqldConfig ¶
type MysqldConfig struct { BaseDir string BindAddress string CopyDataFrom string DataDir string PidFile string Port int SkipNetworking bool Socket string TmpDir string AutoStart int MysqlInstallDb string Mysqld string }
MysqldConfig is used to configure the new mysql instance
func NewConfig ¶
func NewConfig() *MysqldConfig
NewConfig creates a new MysqldConfig struct with default values
type TestMysqld ¶
type TestMysqld struct { Config *MysqldConfig Command *exec.Cmd DefaultsFile string Guards []func() LogFile string }
TestMysqld is the main struct that handles the execution of mysqld
func NewMysqld ¶
func NewMysqld(config *MysqldConfig) (*TestMysqld, error)
NewMysqld creates a new TestMysqld instance configはnilが渡されている
func (*TestMysqld) AssertNotRunning ¶
func (m *TestMysqld) AssertNotRunning() error
AssertNotRunning returns nil if mysqld is not running
func (*TestMysqld) BaseDir ¶
func (m *TestMysqld) BaseDir() string
BaseDir returns the base dir for mysqld
func (*TestMysqld) ConnectString ¶
func (m *TestMysqld) ConnectString(port int) string
ConnectString returns the connect string `tcp(...)` or `unix(...)` This method is deprecated, and will be removed in a future version.
func (*TestMysqld) DSN ¶
func (m *TestMysqld) DSN(options ...DatasourceOption) string
DSN creates a datasource name string that is appropriate for connecting to the database instance started by TestMysqld.
This method respects networking settings and host:port/socket settings, and provide sane defaults for those parameters. If you want to forcefully override them, you still can do so by providing explicit DatasourceOption values
func (*TestMysqld) Datasource ¶
func (m *TestMysqld) Datasource(dbname string, user string, pass string, port int, options ...DatasourceOption) string
Datasource is a DEPRECATED method to create a datasource string that can be passed to sql.Open(). Please consider using `DSN` instead
func (*TestMysqld) ReadLog ¶
func (m *TestMysqld) ReadLog() ([]byte, error)
ReadLog reads the output log file specified by LogFile and returns its content
func (*TestMysqld) Setup ¶
func (m *TestMysqld) Setup() error
Setup sets up all the files and directories needed to start mysqld
func (*TestMysqld) Socket ¶
func (m *TestMysqld) Socket() string
Socket returns the unix socket location