2026-03-30 10:39:35 +02:00
|
|
|
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.
|
2026-05-14 09:00:53 +02:00
|
|
|
func NewTestPostgresDB(t testing.TB) *sqldb.PostgresStore {
|
2026-03-30 10:39:35 +02:00
|
|
|
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)
|
|
|
|
|
}
|