mirror of
https://github.com/lightninglabs/faraday.git
synced 2026-08-13 12:33:35 +02:00
Promote the existing test-store and test-DB constructors from *testing.T to testing.TB so the upcoming EffectiveUptime benchmark can share the same fixture path as the existing tests. testing.TB is the shared interface of *testing.T and *testing.B, so every current caller keeps type-checking unchanged.
25 lines
553 B
Go
25 lines
553 B
Go
package db
|
|
|
|
import (
|
|
"testing"
|
|
|
|
_ "github.com/golang-migrate/migrate/v4/source/file"
|
|
"github.com/lightningnetwork/lnd/sqldb/v2"
|
|
)
|
|
|
|
// NewTestPostgresDB is a helper function that creates a Postgres database for
|
|
// testing.
|
|
func NewTestPostgresDB(t testing.TB) *sqldb.PostgresStore {
|
|
t.Helper()
|
|
|
|
t.Logf("Creating new Postgres DB for testing")
|
|
|
|
sqlFixture := sqldb.NewTestPgFixture(
|
|
t, sqldb.DefaultPostgresFixtureLifetime,
|
|
)
|
|
t.Cleanup(func() {
|
|
sqlFixture.TearDown(t)
|
|
})
|
|
|
|
return sqldb.NewTestPostgresDB(t, sqlFixture, FaradayMigrationSets)
|
|
}
|