Move config to global variable
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2022-04-05 20:00:25 +00:00
parent 95eb302d26
commit 8954cffb7a
2 changed files with 14 additions and 11 deletions

View File

@ -16,19 +16,27 @@ import (
"git.javil.eu/jacob1123/budgeteer/jwt"
"git.javil.eu/jacob1123/budgeteer/postgres"
"git.javil.eu/jacob1123/budgeteer/web"
txdb "github.com/DATA-DOG/go-txdb"
)
var cfg = config.Config{ //nolint:gochecknoglobals
DatabaseConnection: "postgres://budgeteer:budgeteer@db:5432/budgeteer_test",
SessionSecret: "this_is_my_demo_secret_for_unit_tests",
}
func init() { //nolint:gochecknoinits
txdb.Register("pgtx", "pgx", cfg.DatabaseConnection)
}
func TestMain(t *testing.T) {
t.Parallel()
cfg := config.Config{
DatabaseConnection: "postgres://budgeteer:budgeteer@db:5432/budgeteer_test",
SessionSecret: "random string for JWT authorization",
}
_, err := postgres.Connect("pgx", cfg.DatabaseConnection)
if err != nil {
log.Fatalf("Failed connecting to DB: %v", err)
}
queries, err := postgres.Connect("pgtx", cfg.DatabaseConnection)
if err != nil {
log.Fatalf("Failed connecting to DB: %v", err)