Add MySQL support

This commit is contained in:
Adrian Macneil 2015-11-30 22:05:23 -08:00
parent 5211670904
commit c402613c6c
7 changed files with 399 additions and 6 deletions

View file

@ -52,11 +52,25 @@ func postgresTestURL(t *testing.T) *url.URL {
return u
}
func mysqlTestURL(t *testing.T) *url.URL {
str := os.Getenv("MYSQL_PORT")
require.NotEmpty(t, str, "missing MYSQL_PORT environment variable")
u, err := url.Parse(str)
require.Nil(t, err)
u.Scheme = "mysql"
u.User = url.UserPassword("root", "root")
u.Path = "/dbmate"
return u
}
func testURLs(t *testing.T) []*url.URL {
return []*url.URL{
postgresTestURL(t),
mysqlTestURL(t),
}
}
func mustClose(c io.Closer) {
@ -178,7 +192,8 @@ func testRollbackCommandURL(t *testing.T, u *url.URL) {
require.Equal(t, 0, count)
err = db.QueryRow("select count(*) from users").Scan(&count)
require.Equal(t, "pq: relation \"users\" does not exist", err.Error())
require.NotNil(t, err)
require.Regexp(t, "(does not exist|doesn't exist)", err.Error())
}
func TestRollbackCommand(t *testing.T) {