summaryrefslogtreecommitdiff
path: root/testrig/db.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2021-09-10 18:13:24 +0200
committerLibravatar GitHub <noreply@github.com>2021-09-10 18:13:24 +0200
commit64bd689e557099f32dfaf5209ce55bc08ae3aca1 (patch)
tree45ef640e98136d461af8c71c96ec919bbe881061 /testrig/db.go
parentmigrate go version to 1.17 (#203) (diff)
downloadgotosocial-64bd689e557099f32dfaf5209ce55bc08ae3aca1.tar.xz
Test both dbs (#205)
* move scripts, allow testing both dbs with one cmd * tidy + vendor * update test.sh to ignore cache * put test commands directly in drone.yml * change CONTRIBUTING slightly * go ham on the readme
Diffstat (limited to 'testrig/db.go')
-rw-r--r--testrig/db.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/testrig/db.go b/testrig/db.go
index 268ba16b7..3de21c25d 100644
--- a/testrig/db.go
+++ b/testrig/db.go
@@ -21,6 +21,7 @@ package testrig
import (
"context"
"os"
+ "strconv"
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/db"
@@ -58,6 +59,12 @@ var testModels []interface{} = []interface{}{
//
// If the environment variable GTS_DB_ADDRESS is set, it will take that
// value as the database address instead.
+//
+// If the environment variable GTS_DB_TYPE is set, it will take that
+// value as the database type instead.
+//
+// If the environment variable GTS_DB_PORT is set, it will take that
+// value as the port instead.
func NewTestDB() db.DB {
config := NewTestConfig()
alternateAddress := os.Getenv("GTS_DB_ADDRESS")
@@ -65,6 +72,20 @@ func NewTestDB() db.DB {
config.DBConfig.Address = alternateAddress
}
+ alternateDBType := os.Getenv("GTS_DB_TYPE")
+ if alternateDBType != "" {
+ config.DBConfig.Type = alternateDBType
+ }
+
+ alternateDBPort := os.Getenv("GTS_DB_PORT")
+ if alternateDBPort != "" {
+ port, err := strconv.ParseInt(alternateDBPort, 10, 64)
+ if err != nil {
+ panic(err)
+ }
+ config.DBConfig.Port = int(port)
+ }
+
testDB, err := bundb.NewBunDBService(context.Background(), config, NewTestLog())
if err != nil {
logrus.Panic(err)