lightning-terminal/firewalldb/test_postgres.go
Viktor Tigerström 24ef4201c9
firewalldb: update NewTestDB funcs to return FirewallDBs
In the upcoming migration of the firewall database to SQL, the helper
functions that creates the test databases of different types, need to
return a unified interface in order to not have to control the
migration tests file by build tags. Therefore, we update the
`NewTestDB` functions to return the `FirewallDBs` interface instead of
the specific store implementation type.
2025-07-21 14:45:45 +02:00

21 lines
667 B
Go

//go:build test_db_postgres && !test_db_sqlite
package firewalldb
import (
"testing"
"github.com/lightninglabs/lightning-terminal/db"
"github.com/lightningnetwork/lnd/clock"
)
// NewTestDB is a helper function that creates an BBolt database for testing.
func NewTestDB(t *testing.T, clock clock.Clock) FirewallDBs {
return createStore(t, db.NewTestPostgresDB(t).BaseDB, clock)
}
// NewTestDBFromPath is a helper function that creates a new BoltStore with a
// connection to an existing BBolt database for testing.
func NewTestDBFromPath(t *testing.T, _ string, clock clock.Clock) FirewallDBs {
return createStore(t, db.NewTestPostgresDB(t).BaseDB, clock)
}