diff options
Diffstat (limited to 'testrig')
| -rw-r--r-- | testrig/db.go | 21 | 
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)  | 
