mirror of
https://github.com/TECHNOFAB11/dbmate.git
synced 2025-12-12 16:10:03 +01:00
Add MySQL support
This commit is contained in:
parent
5211670904
commit
c402613c6c
7 changed files with 399 additions and 6 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue