Skip to content

Commit

Permalink
fix: NewDB() returns empty db name
Browse files Browse the repository at this point in the history
  • Loading branch information
moshloop committed Jan 1, 2024
1 parent 22ea984 commit 566b467
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions tests/setup/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var dummyData dummy.DummyData

var PgUrl string
var postgresDBUrl string
var dbName string
var dbName = "test"
var trace bool
var dbTrace bool

Expand Down Expand Up @@ -64,7 +64,6 @@ func MustDB() *sql.DB {
var WithoutDummyData = "without_dummy_data"

func BeforeSuiteFn(args ...interface{}) context.Context {

var err error
importDummyData := true

Expand All @@ -81,7 +80,7 @@ func BeforeSuiteFn(args ...interface{}) context.Context {

port := FreePort()

PgUrl = fmt.Sprintf("postgres://postgres:postgres@localhost:%d/test?sslmode=disable", port)
PgUrl = fmt.Sprintf("postgres://postgres:postgres@localhost:%d/%s?sslmode=disable", port, dbName)
url := os.Getenv("DUTY_DB_URL")
if url != "" {
postgresDBUrl = url
Expand All @@ -92,7 +91,7 @@ func BeforeSuiteFn(args ...interface{}) context.Context {
panic(fmt.Sprintf("Cannot create %s: %v", dbName, err))
}
} else {
config, _ := GetEmbeddedPGConfig("test", port)
config, _ := GetEmbeddedPGConfig(dbName, port)
postgresServer = embeddedPG.NewDatabase(config)
if err = postgresServer.Start(); err != nil {
panic(err.Error())
Expand Down

0 comments on commit 566b467

Please sign in to comment.