2025-04-05 19:24:48 +02:00
|
|
|
//go:build !test_db_posgres && test_db_sqlite
|
|
|
|
|
|
|
|
|
|
package graphdb
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"database/sql"
|
|
|
|
|
"testing"
|
|
|
|
|
|
2025-05-24 15:41:32 +02:00
|
|
|
"github.com/btcsuite/btcd/chaincfg"
|
2025-04-05 19:24:48 +02:00
|
|
|
"github.com/lightningnetwork/lnd/sqldb"
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// NewTestDB is a helper function that creates a SQLStore backed by a sqlite
|
2025-06-30 12:33:43 +02:00
|
|
|
// database for testing.
|
2025-05-19 13:43:09 +02:00
|
|
|
func NewTestDB(t testing.TB) V1Store {
|
2025-04-05 19:24:48 +02:00
|
|
|
db := sqldb.NewTestSqliteDB(t).BaseDB
|
|
|
|
|
|
|
|
|
|
executor := sqldb.NewTransactionExecutor(
|
|
|
|
|
db, func(tx *sql.Tx) SQLQueries {
|
|
|
|
|
return db.WithTx(tx)
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
|
2025-05-24 15:41:32 +02:00
|
|
|
store, err := NewSQLStore(
|
|
|
|
|
&SQLStoreConfig{
|
|
|
|
|
ChainHash: *chaincfg.MainNetParams.GenesisHash,
|
2025-06-11 18:17:10 +02:00
|
|
|
}, executor,
|
2025-05-24 15:41:32 +02:00
|
|
|
)
|
2025-05-23 11:00:29 +02:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
return store
|
2025-04-05 19:24:48 +02:00
|
|
|
}
|