Create real MySQL server instance for testing
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 31 commits behind lestrrat-go:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
copy_data_from/test
.gitignore
.travis.yml
LICENSE
README.md
mysqltest.go
mysqltest_test.go

README.md

go-test-mysqld

Build Status

Create real MySQL server instance for testing

To install, simply issue a go get:

go get github.com/lestrrat/go-test-mysqld

By default importing github.com/lestrrat/go-test-mysqld will import package mysqltest

import (
    "database/sql"
    "log"
    "github.com/lestrrat/go-test-mysqld"
)

mysqld, err := mysqltest.NewMysqld(nil)
if err != nil {
   log.Fatalf("Failed to start mysqld: %s", err)
}
defer mysqld.Stop()

db, err := sql.Open("mysql", mysqld.Datasource("test", "", "", 0))
// Now use db, which is connected to a mysql db

go-test-mysqld is a port of Test::mysqld

When you create a new struct via NewMysqld() a new mysqld instance is automatically setup and launched. Don't forget to call Stop() on this struct to stop the launched mysqld

If you want to customize the configuration, create a new config and set each field on the struct:

config := mysqltest.NewConfig()
config.SkipNetworking = false
config.Port = 13306

// Starts mysqld listening on port 13306
mysqld, _ := mysqltest.NewMysqld(config)

TODO

  • CopyDataFrom is not implemented.