2019-06-11 12:47:35 +02:00
|
|
|
package dbconfig
|
|
|
|
|
|
2021-10-21 13:39:24 +02:00
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"github.com/go-jet/jet/v2/tests/internal/utils/repo"
|
|
|
|
|
)
|
2019-06-11 12:47:35 +02:00
|
|
|
|
2019-07-29 18:08:53 +02:00
|
|
|
// Postgres test database connection parameters
|
2019-06-11 12:47:35 +02:00
|
|
|
const (
|
2021-07-27 17:39:21 +02:00
|
|
|
PgHost = "localhost"
|
2021-12-17 16:59:43 +01:00
|
|
|
PgPort = 50901
|
2021-07-27 17:39:21 +02:00
|
|
|
PgUser = "jet"
|
|
|
|
|
PgPassword = "jet"
|
|
|
|
|
PgDBName = "jetdb"
|
2019-06-11 12:47:35 +02:00
|
|
|
)
|
|
|
|
|
|
2019-07-29 18:08:53 +02:00
|
|
|
// PostgresConnectString is PostgreSQL test database connection string
|
2021-07-27 17:39:21 +02:00
|
|
|
var PostgresConnectString = fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s sslmode=disable", PgHost, PgPort, PgUser, PgPassword, PgDBName)
|
2019-07-29 18:08:53 +02:00
|
|
|
|
|
|
|
|
// MySQL test database connection parameters
|
|
|
|
|
const (
|
2021-12-18 13:55:40 +01:00
|
|
|
MySqLHost = "127.0.0.1"
|
2021-12-17 16:59:43 +01:00
|
|
|
MySQLPort = 50902
|
2019-07-29 18:08:53 +02:00
|
|
|
MySQLUser = "jet"
|
|
|
|
|
MySQLPassword = "jet"
|
2021-12-17 16:59:43 +01:00
|
|
|
|
2021-12-18 13:55:40 +01:00
|
|
|
MariaDBHost = "127.0.0.1"
|
2021-12-17 16:59:43 +01:00
|
|
|
MariaDBPort = 50903
|
|
|
|
|
MariaDBUser = "jet"
|
|
|
|
|
MariaDBPassword = "jet"
|
2019-07-29 18:08:53 +02:00
|
|
|
)
|
|
|
|
|
|
2021-12-17 16:59:43 +01:00
|
|
|
// MySQLConnectionString is MySQL connection string for test database
|
|
|
|
|
func MySQLConnectionString(isMariaDB bool, dbName string) string {
|
|
|
|
|
if isMariaDB {
|
|
|
|
|
return fmt.Sprintf("%s:%s@tcp(%s:%d)/%s", MariaDBUser, MariaDBPassword, MariaDBHost, MariaDBPort, dbName)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return fmt.Sprintf("%s:%s@tcp(%s:%d)/%s", MySQLUser, MySQLPassword, MySqLHost, MySQLPort, dbName)
|
|
|
|
|
}
|
2021-10-21 13:39:24 +02:00
|
|
|
|
|
|
|
|
// sqllite
|
|
|
|
|
var (
|
|
|
|
|
SakilaDBPath = repo.GetTestDataFilePath("/init/sqlite/sakila.db")
|
|
|
|
|
ChinookDBPath = repo.GetTestDataFilePath("/init/sqlite/chinook.db")
|
|
|
|
|
TestSampleDBPath = repo.GetTestDataFilePath("/init/sqlite/test_sample.db")
|
|
|
|
|
)
|