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
This commit is contained in:
tobi 2021-09-10 18:13:24 +02:00 committed by GitHub
commit 64bd689e55
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 337 additions and 196 deletions

View file

@ -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)