jet/tests/dbconfig/dbconfig.go

48 lines
1.3 KiB
Go
Raw Normal View History

2019-06-11 12:47:35 +02:00
package dbconfig
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 (
PgHost = "localhost"
PgPort = 50901
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
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 (
MySqLHost = "localhost"
MySQLPort = 50902
2019-07-29 18:08:53 +02:00
MySQLUser = "jet"
MySQLPassword = "jet"
MariaDBHost = "localhost"
MariaDBPort = 50903
MariaDBUser = "jet"
MariaDBPassword = "jet"
2019-07-29 18:08:53 +02: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)
}
// sqllite
var (
SakilaDBPath = repo.GetTestDataFilePath("/init/sqlite/sakila.db")
ChinookDBPath = repo.GetTestDataFilePath("/init/sqlite/chinook.db")
TestSampleDBPath = repo.GetTestDataFilePath("/init/sqlite/test_sample.db")
)