Add support for running integration tests with dockerized test databases.

This commit is contained in:
go-jet 2021-12-17 16:59:43 +01:00
parent 4d5abc85c6
commit 972fc1d9bf
13 changed files with 210 additions and 67 deletions

6
tests/init/Readme.md Normal file
View file

@ -0,0 +1,6 @@
The `init` command can be used to initialize test databases on the local host machine, if needed.
Update [dbconfig](../dbconfig/dbconfig.go) with your local database parameters.
The recommended way to initialize test databases is by a docker container.
See tests [Readme.md](../Readme.md).

View file

@ -71,8 +71,13 @@ func initMySQLDB() {
}
for _, dbName := range mySQLDBs {
cmdLine := fmt.Sprintf("mysql -h 127.0.0.1 -u %s -p%s %s < %s",
dbconfig.MySQLUser, dbconfig.MySQLPassword, dbName, "./testdata/init/mysql/"+dbName+".sql")
cmdLine := fmt.Sprintf("mysql -h %s -P%d -u %s -p%s %s < %s",
dbconfig.MySqLHost,
dbconfig.MySQLPort,
dbconfig.MySQLUser,
dbconfig.MySQLPassword,
dbName,
"./testdata/init/mysql/"+dbName+".sql")
fmt.Println(cmdLine)