diff options
Diffstat (limited to '')
-rw-r--r-- | tests/internal/utils/database.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/internal/utils/database.go b/tests/internal/utils/database.go new file mode 100644 index 0000000..c32566b --- /dev/null +++ b/tests/internal/utils/database.go @@ -0,0 +1,28 @@ +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 +} |