Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Commit

Permalink
Provide a way to return config from the test database (#503)
Browse files Browse the repository at this point in the history
  • Loading branch information
sethvargo authored May 31, 2020
1 parent 208bab6 commit 70e20df
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion internal/database/database_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import (
//
// All database tests can be skipped by running `go test -short` or by setting
// the `SKIP_DATABASE_TESTS` environment variable.
func NewTestDatabase(tb testing.TB) *DB {
func NewTestDatabaseWithConfig(tb testing.TB) (*DB, *Config) {
tb.Helper()

if testing.Short() {
Expand Down Expand Up @@ -126,6 +126,20 @@ func NewTestDatabase(tb testing.TB) *DB {
db.Close(context.Background())
})

return db, &Config{
Name: dbname,
User: username,
Host: container.GetBoundIP("5432/tcp"),
Port: container.GetPort("5432/tcp"),
SSLMode: "disable",
Password: password,
}
}

func NewTestDatabase(tb testing.TB) *DB {
tb.Helper()

db, _ := NewTestDatabaseWithConfig(tb)
return db
}

Expand Down

0 comments on commit 70e20df

Please sign in to comment.