lightning-terminal/accounts/test_kvdb.go
Viktor Torstensson 9c6464f7e4
accounts: export kvdb DB
The next commit that adds the kvdb to sql code migration will need to
initialize the accounts kvdb DB.

This commit exports that struct so that it can be referenced outside of
the accounts package.
2026-05-14 11:38:32 +02:00

35 lines
903 B
Go

//go:build !test_db_sqlite && !test_db_postgres
package accounts
import (
"errors"
"testing"
"github.com/lightningnetwork/lnd/clock"
"github.com/stretchr/testify/require"
)
// ErrDBClosed is an error that is returned when a database operation is
// performed on a closed database.
var ErrDBClosed = errors.New("database not open")
// NewTestDB is a helper function that creates an BBolt database for testing.
func NewTestDB(t *testing.T, clock clock.Clock) Store {
return NewTestDBFromPath(t, t.TempDir(), 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, dbPath string,
clock clock.Clock) Store {
store, err := NewBoltStore(dbPath, DBFilename, clock)
require.NoError(t, err)
t.Cleanup(func() {
require.NoError(t, store.DB.Close())
})
return store
}