diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..57f1cb2a7a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.idea/ \ No newline at end of file diff --git a/README.md b/README.md index e6aa16d391..81d9c3074a 100644 --- a/README.md +++ b/README.md @@ -480,7 +480,9 @@ go test --tags=exp ./... To run the tests in the examples folder, a running PostgreSQL instance is required. The tests use the following environment variables to connect to the -database: +database + +#### For PostgreSQL ``` Variable Default Value @@ -492,6 +494,18 @@ PG_PASSWORD mysecretpassword PG_DATABASE dinotest ``` +#### For MySQL + +``` +Variable Default Value +------------------------- +MYSQL_HOST 127.0.0.1 +MYSQL_PORT 3306 +MYSQL_USER root +MYSQL_ROOT_PASSWORD mysecretpassword +MYSQL_DATABASE dinotest +``` + ``` go test --tags=examples,exp ./... ``` diff --git a/internal/sqltest/mysql.go b/internal/sqltest/mysql.go index d1cf92e6ad..f793e42a59 100644 --- a/internal/sqltest/mysql.go +++ b/internal/sqltest/mysql.go @@ -76,5 +76,10 @@ func MySQL(t *testing.T, migrations []string) (*sql.DB, func()) { } } - return sdb, func() {} + return sdb, func() { + // Drop the test db after test runs + if _, err := db.Exec("DROP DATABASE " + dbName); err != nil { + t.Fatal(err) + } + } }