mirror of
https://github.com/Icinga/icingadb.git
synced 2026-02-03 20:40:34 -05:00
28 lines
578 B
Go
28 lines
578 B
Go
package utils
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/icinga/icinga-testing"
|
|
"github.com/icinga/icinga-testing/services"
|
|
"os"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func GetDatabase(it *icingatesting.IT, t testing.TB) services.RelationalDatabase {
|
|
k := "ICINGADB_TESTS_DATABASE_TYPE"
|
|
v := strings.ToLower(os.Getenv(k))
|
|
|
|
var rdb services.RelationalDatabase
|
|
|
|
switch v {
|
|
case "mysql":
|
|
rdb = it.MysqlDatabaseT(t)
|
|
case "pgsql":
|
|
rdb = it.PostgresqlDatabaseT(t)
|
|
default:
|
|
panic(fmt.Sprintf(`unknown database in %s environment variable: %q (must be "mysql" or "pgsql")`, k, v))
|
|
}
|
|
|
|
return rdb
|
|
}
|