mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-10 22:27:22 +01:00
Factor out the transaction executor construction so that we can have access to the raw BatchedSQLQueries type from within tests.
30 lines
607 B
Go
30 lines
607 B
Go
//go:build test_db_postgres && !test_db_sqlite
|
|
|
|
package graphdb
|
|
|
|
import (
|
|
"database/sql"
|
|
"testing"
|
|
|
|
"github.com/lightningnetwork/lnd/sqldb"
|
|
)
|
|
|
|
// newBatchQuerier creates a new BatchedSQLQueries instance for testing
|
|
// using a PostgreSQL database fixture.
|
|
func newBatchQuerier(t testing.TB) BatchedSQLQueries {
|
|
pgFixture := sqldb.NewTestPgFixture(
|
|
t, sqldb.DefaultPostgresFixtureLifetime,
|
|
)
|
|
t.Cleanup(func() {
|
|
pgFixture.TearDown(t)
|
|
})
|
|
|
|
db := sqldb.NewTestPostgresDB(t, pgFixture).BaseDB
|
|
|
|
return sqldb.NewTransactionExecutor(
|
|
db, func(tx *sql.Tx) SQLQueries {
|
|
return db.WithTx(tx)
|
|
},
|
|
)
|
|
}
|