paymentsdb: move db interface dependant tests to different file

This commit starts reusing test cases which are not dependant on
the kv db backend. So they can be later used with the native db
implementation as well.
This commit is contained in:
ziggie committed 2025-08-20 09:07:52 +02:00
1 parent 39b7417797
commit e22b898c1e
3 files changed
+998 -972

No files matched your search

+18 -1
View File
@@ -8,7 +8,24 @@ import (
)
// NewTestDB is a helper function that creates an BBolt database for testing.
func NewTestDB(t *testing.T, opts ...OptionModifier) *KVPaymentsDB {
func NewTestDB(t *testing.T, opts ...OptionModifier) DB {
backend, backendCleanup, err := kvdb.GetTestBackend(
t.TempDir(), "paymentsDB",
)
require.NoError(t, err)
t.Cleanup(backendCleanup)
paymentDB, err := NewKVPaymentsDB(backend, opts...)
require.NoError(t, err)
return paymentDB
}
// NewKVTestDB is a helper function that creates an BBolt database for testing
// and there is no need to convert the interface to the KVPaymentsDB because for
// some unit tests we still need access to the kvdb interface.
func NewKVTestDB(t *testing.T, opts ...OptionModifier) *KVPaymentsDB {
backend, backendCleanup, err := kvdb.GetTestBackend(
t.TempDir(), "kvPaymentDB",
)