From 64bd689e557099f32dfaf5209ce55bc08ae3aca1 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Fri, 10 Sep 2021 18:13:24 +0200 Subject: 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 --- testrig/db.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'testrig/db.go') 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) -- cgit v1.2.3